Question: write a lottery program in java. The Lottery program randomly generates a three-digit lottery number, prompts the user to enter any three-digit number, and determines
write a lottery program in java.
The Lottery program randomly generates a three-digit lottery number, prompts the user to enter any three-digit number, and determines whether the user wins according to the following rules:
If the user input matches the lottery number in the exact order, the award is $10,000.
If any two digits in the user input match two digits in the lottery number in the exact position, the award is $3,000.
If one digit in the user input matches a digit in the lottery number in the exact position, the award is $1,000.
If at least one digit match any digit in the lottery number, in the incorrect position, the award is $10.
Additional rules:
The digits of a three-digit number may be 0 (zero). If a number is less than 1000, you may assume the number is preceded by one or two zeros to form a three-digit number. For example, number 80 is treated as 080, number 8 is treated as 008 and number 0 is treated as 000 in the program.
The prizes are not cumulative. For example:
if the lottery number is 123, and the user guesses 321, the prize is $1000 for matching one digit in the correct position (2). There is no extra prize for the two other digits in the incorrect position.
if the lottery number is 123, and the user guesses 341, the prize is $10 for matching any digit in an incorrect position. There is no extra prize for the second digit in an incorrect position.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
