Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

n 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. 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.

***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: 10 Too low, dimwit!

Enter your guess: 15 You win!!

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

Step: 3

blur-text-image

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

Implementing Ai And Machine Learning For Business Optimization

Authors: Robert K Wiley

1st Edition

B0CPQJW72N, 979-8870675855

More Books

Students also viewed these Databases questions

Question

d. Would you implement the new control algorithm?

Answered: 1 week ago