Question: In Java Your program should first pick a random number between 1 and 100. Then the user guesses the number. Your program should say whether

In Java

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. Your program must include at least one function/method to receive full credit.

***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!!

Random Numbers

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());

In general, to get a random number in the range 1-n, use this: number = (int)(1+n*Math.random());

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. For another 3 points of extra credit, 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. NOTE: The insult chosen must not, in any way, depend on how close the user is to guessing the number, or depend on whether they are too high or low.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!