Question: In Java write a program that plays the Guessing Game . Your program should first pick a random number between 1 and 100. Then the
In Java write a program that plays the Guessing Game. Your program should first pick a random number between 1 and 100. Then the user guesses the number. Your program should say whether the guess is too high, too low, or correct. If the guess was correct, the program stops. Otherwise, the user gets to guess again. After the game is over, ask the user if he/she wants to play again. If so, choose a new random number and start over. The user should be allowed to play as many times as he/she desires. Have the computer display different insults. The idea is to pick a random number and use if statements to decide which insult to use. Use a list of at least 5 possible insults.
To create a random number in the range 1-100 and place it in the integer variable number, do the following:
number = (int)(1+100*Math.random());
***Welcome to the GUESSING GAME!!*** I have a number between 1 and 100. Can you guess it? Enter your guess: 70 Too high, elbow nose! Enter your guess: 35 Too high, elbow nose! Enter your guess: 10 Too low, dimwit! Enter your guess: 15 You win!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
