I am trying to create a lottery game application in Java. I want it to generate three random numbers between 0 and 9 (including 0 and 9). Then, the user will input their three guesses of what the winning numbers will be. Next, compare each of the user's guesses to the three random numbers and display a message that includes the user's guess, the randomly determined three digits, and the amount of money the user has won. I need to make certain that this application accommodates repeating digits. For example, if a user guesses 1, 2, and 3, and the randomly generated digits are 1, 1, and 1, do not give the user credit for three correct guesses-just one. (From this, it stands to reason that if the randomly generated digits include 2 repeated digits, that they also should be counted as-just one.) This is an example of the final output I am hoping to achieve with this program: Guess the 3 numbers I have chosen. Guess 1 right $10 Guess 2 right $100 Guess 3 right (any order) $1,000 Guess 3 right (exact order) $1,000,000 Enter the 1st number: 1 Enter the 2nd number: 4 Enter the 3rd number: 5 Computer picks: 1 2 3 You guessed: 1 4 5 1 Match, you win $10 I want to try and identify ALL test cases. A test case will include the input necessary to create an expected output. So far in my program, I have:
I am trying to create a lottery game application in Java. I want it to generate three random numbers between 0 and 9 (including 0 and 9). Then, the user will input their three guesses of what the winning numbers will be. Next, compare each of the user's guesses to the three random numbers and display a message that includes the user's guess, the randomly determined three digits, and the amount of money the user has won. I need to make certain that this application accommodates repeating digits. For example, if a user guesses 1, 2, and 3, and the randomly generated digits are 1, 1, and 1, do not give the user credit for three correct guesses-just one. (From this, it stands to reason that if the randomly generated digits include 2 repeated digits, that they also should be counted as-just one.)
This is an example of the final output I am hoping to achieve with this program:
Guess the 3 numbers I have chosen.
Guess 1 right $10
Guess 2 right $100
Guess 3 right (any order) $1,000
Guess 3 right (exact order) $1,000,000
Enter the 1st number: 1
Enter the 2nd number: 4
Enter the 3rd number: 5
Computer picks: 1 2 3 You guessed: 1 4 5
1 Match, you win $10
I want to try and identify ALL test cases. A test case will include the input necessary to create an expected output.
So far in my program, I have:
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 6 images