Question: using java and without using loops 5. Variation of the Lottery Problem: Write a Java program that first generates a random 3-digit positive integer; then

 using java and without using loops 5. Variation of the Lottery
using java and without using loops

5. Variation of the Lottery Problem: Write a Java program that first generates a random 3-digit positive integer; then prompts the user to enter a 3-digit integer him-/herself; then compares the random integer with the user-entered integer and does the following: - If the numbers exactly match: "Congratulations! You won the lottery $10,000 prize!"; - If any 2 out of 3 digits match: "Congrats - you won the second prize of $500!"; - If exactly one digit matches: You won $10"; - If no digits match: "Sorry, you did not win" gets printed on the screen by your code. - If the user entered anything other than a valid 3-digit (positive) integer, your program should warn her/him: "Please try again: enter a positive 3-digit number" (Note: you need to use the Math.random method from Chapter 4 in this problem; for the rest of this assignment, Java features just from Chapters 1 - 3 in Liang suffice.) EXAMPLE: Assume the lottery number is 123 and that Mary picked 100, Bob picked 217 and Ivan picked 723. Then Mary would win $10 (as only one digit matches '123' at the correct position), Bob would not win anything and Ivan would win $500 for two matched digits

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 Databases Questions!