Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

Which class contains the method for checking whether a file exists?

Answered: 1 week ago