Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called GuessTheNumber that generates a random number between 1 and 10, inclusive. It will then ask the user to guess the number

Create a class called GuessTheNumber that generates a random number between 1 and 10, inclusive. It will then ask the user to guess the number between 1 and 10, inclusive, and display one of the following messages:

Your guess is too high

Your guess is too low

You guessed correctly in nn guesses!

If the user guesses incorrectly, indicate if the guess was too high or too low, and continue asking for a guess until the user guesses the number. The class should count the number of guesses it took the user, and display that value for nn.

The class should have at least the following two methods: a public method named play which actually plays the game; and private method named askForNumber which asks the user for their guess. Make sure to perform error checking on the users input.

Create a second class called GuessTheNumberTest that plays the game. The class should play the game at least once, and then ask the user if they would like to play the game again. Keep playing the game until the user decides they want to stop

For all both classes, comment all method, and at the start of any control statements.

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago

Question

3. The group answers the questions.

Answered: 1 week ago