Question: Write a java program that generates a random integer between 0 and 9. The program then gives the user 3 chances to guess it. If

Write a java program that generates a random integer between 0 and 9. The program then gives the user 3 chances to guess it. If the user guesses the number, the program prints the message Congratulations!. If the user doesnt guess the number after three attempts, the program displays Bad luck! Sample run 1: Im thinking about a number in [0, 9]. Can you guess it? (attempt #1): 5 Im thinking about a number in [0, 9]. Can you guess it? (attempt #2): 3 Im thinking about a number in [0, 9]. Can you guess it? (attempt #3): 8 Bad luck! The correct number is 1. Sample run 2: Im thinking about a number in [0, 9]. Can you guess it? (attempt #1): 5 Congratulations! The correct number is 5.

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!