I am working on this lottery code but experiencing an endless run. i would appreciate pointing out what may be wrong with the code and how to go about rectifying it. Thank you. The question is "to generate a lottery like https://loteriasdehoycolombia.co/ of a two digit number. The two digits in the number are distinct. (Hint: Generate the first digit. Use a loop to continuously generate the second digit until it is different from the first digit.)
public class Lottery1 {
public static void main(String[] args) {
// Create Scanner
Scanner s = new Scanner(System.in);
//generate 2 digit random lottery number
int lottery = (int) (Math.random() * 100);
// TODO code application logic here
//generate first and second digit of lottery
int lotterydigit1 = lottery / 10;
int lotterydigit2 = lottery % 10;
while (lotterydigit2 != lotterydigit1) {
lotterydigit2 = lottery % 10;
}
//prompt user for guess digits
System.out.print("Enter two Digit number:");
int guess = s.nextInt();
int guessdigit1 = guess / 10;
int guessdigit2 = guess % 10;
// compare lottery and
if (guessdigit1 == lotterydigit1 && guessdigit2 == lotterydigit2) {
System.out.println("You just won $10,0000");
} else if (guessdigit1 == lotterydigit2 && guessdigit2 == lotterydigit1) {
System.out.println("You have won $5,000");
} else if (guessdigit1 == lotterydigit1
|| guessdigit1 == lotterydigit2
|| guessdigit2 == lotterydigit1
|| guessdigit2 == lotterydigit2) {
System.out.println("You have won $1,000");
} else {
System.out.println("You have not won anything");
}
System.out.println("lottery number is" + " " + lottery + " and your guess is" + guess);
}
}