Create a java Program,In this question you are asked to write a lottery game application. Your program must first display a welcome message/banner asking the human player for his/her given name.
Create the following program in java:
Create a java Program,In this question you are asked to write a lottery game application. Your program must first display a welcome message/banner asking the human player for his/her given name.
Generate a random number between 0 and 999, which you are to store in a single variable (int). Allow the user to guess a three digit number between 0 and 999, which you are also to store in a single variable of type int.
Compare the user’s guess to the random number and display a message that includes the user’s name, user’s guess, the randomly determined three-digit number and the amount of money the user has won as follows:
Matching digits Awards
Any one matching. $10
Two matching. $100
Three matching not in order. $1000
Three matching in exact order. $1,000,000
No matches. $0
Make sure that your application accommodates repeated digits. For example if a user guesses 123 and the randomly generated number is 111, do not give the user credit for three correct guesses – just one. On the other hand if the user guesses 121 the user gets credit for 2 correct guesses. Note that the 3 digitnumber can start with a 0 or even 2 zeroes. When displaying these numbers be sure to include the zeroes in the front.
Sample output:
********* welcome to lottery game******
what is your name
Annna
welcome Annna
Enter a three digit number followed by enter key
123
The lotto number was 897
The number u gave was 123
There have been no matches u win $0
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images