Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Guessing Game Class in java The class will generate a random number of 1 to 15, and then check to see if the user guessed

Guessing Game Class in java

The class will generate a random number of 1 to 15, and then check to see if the user guessed the number correctly. If the number is incorrect, the user should have the chance to guess again, until they guess the right number or they guess 10 times. The program should keep track of the number of guesses the user has had, and print this value at the end.

The class should have one defined Constructor. This constructor should call on a private method within the class to generate the random number; and set the private data field with the number generated. It should also have a method to check the guess to see if it was correct. The guessing method should return a Boolean value to determine if the user keeps guessing. The class should have a method that returns a Boolean value to check the users input to see if it is valid.

After each guess, the program should print out the users guess and how many guesses they have left. If the guess was incorrect at the end of the program, the program should print out that the user had 10 guesses that were incorrect, and should print out the correct random number from the class. If the guess was correct, the program should print out how many guesses it took to get the correct answer.

There should be a seperate class that the program should be able to use. The class should be named Guess and the program to run the class should be named GuessingGame.

Only allowed to import java.util Random and java.util Scanner.

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_2

Step: 3

blur-text-image_3

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Explain the impact of organizational culture on employees.

Answered: 1 week ago