Question: Write a program that plays a guessing game with the user. The program should generate a random number between 1 and some maximum (such as

Write a program that plays a guessing game with the user. The program should generate a random number between 1 and some maximum (such as 100 ), then prompt the user repeatedly to guess the number. When the user guesses incorrectly, the game should give the user a hint about whether the correct answer is higher or lower than the guess. Once the user guesses correctly, the program should print a message showing the number of guesses that the user made. Consider extending this program by making it play multiple games until the user chooses to stop and then printing statistics about the player’s total and average number of guesses.

Step by Step Solution

3.32 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class Guess public static final int MAXGUESS 100 public static void mainString args Scanner console new ScannerSystemin giveIntro int numGames 0 int totGuesses 0 int maxGuesses 0 String again y... View full answer

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 Building Java Programs A Back to Basics Approach Questions!