Question: You are to write a program in Java to simulate a lottery. The Player will select five numbers from 1 to 6 9 . The

You are to write a program in Java to simulate a lottery. The Player will select five numbers from 1 to 69. The computer will generate 5 random numbers from 1 to 69.
Jackpot defined for this assignment:
The grand prize jackpot starts at 10 million. The player will win this amount if all 5 of the players numbers match all five of the computer numbers. Each time the grand prize jackpot is not won in a game, the jackpot will increase by 2 million. If any numbers are matched the player will be assigned a winning of $100 for each matched number.
The player will then be asked if they want to play again. Your code will run until the user wants to stop.
The specifications of the project are as follows:
You must have a user defined class within the code. Code done in only one main method will not be accepted
You will have the following methods:
Method to generate the computer numbers and prompt the player to enter their numbers
Method to check for matches and assign winnings
Method to print results of current game (one set of 5 numbers from the player and the computer)
Method to print all of the final results after the player is done playing
You must use an array of 5 integers for the players numbers and another array of 5 integers for the computer generated lottery numbers. If your code does not have the data defined this way, the code will not be accepted.
How the program will work:
Create code to randomly generate 5 lottery numbers. You will have to check that the computer generates 5 unique numbers from 1 to 69
Create code to prompt the player to enter 5 numbers. You will have to check that the player enters 5 unique numbers from 1 to 69. But you do not have to check for any other data input errors.
You will then check for a match of the players numbers and the lottery numbers. You will keep track of how many numbers matched and any money won.
You will print out the results of the play (numbers matched and any money won in that single game)
If the jackpot was not won, you will add 2 million to the jackpot. If the jackpot was won, you will start the jackpot over at 10 million again
You will ask the player if they want to play again. You must keep track of a running total of what was won and how many times the player played the lottery game
Finally, after the player has quit playing, you are to print:
The number of times the player played the lottery
The number of times a number was matched
The total amount of money won
The final value of the jackpot

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!