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 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 guess the number, or depend on whether they are too high or low.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started