Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that generates a random number between 1 and 10 and asks the user to guess what the number is. Your program should
Write a program that generates a random number between 1 and 10 and asks the user to guess what the number is. Your program should operate similar to mine, who's output is shown below: ========================================================= $ java Lab5 enter a number between 1 and 10: 5 Your guess of 5 is too low. enter a number between 1 and 10: 7 Your guess of 7 is too high. enter a number between 1 and 10: 6 Your guess of 6 is CORRECT! Your guesses were: 5 7 6 ========================================================= Your program should give the user a maximum of five guesses. After five guesses, the program should display a message and exit as shown below: ========================================================= $ java Lab5 enter a number between 1 and 10: 5 Your guess of 5 is too low. enter a number between 1 and 10: 4 Your guess of 4 is too low. enter a number between 1 and 10: 3 Your guess of 3 is too low. (a particularly unskilled player!) enter a number between 1 and 10: 2 Your guess of 2 is too low. enter a number between 1 and 10: 1 Your guess of 1 is too low. Better luck next time! Your guesses were: 5 4 3 2 1 ========================================================= Note in both sets of output that the program keeps track of the guesses as the user makes them and then displays the guesses at the end of the game. To keep your program as simple as possible at first, wait and add this feature on after you have the basic game functioning.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started