Question
Create a program that generates a random number from 1 to 1000. Then, ask the user to guess the random number. If the user's guess
Create a program that generates a random number from 1 to 1000. Then, ask the user to guess the random number.
- If the user's guess is too high, then the program should print "Too High, Try again".
- If the user's guess is too low, then the program should print "Too low, Try again".
Use a loop to allow the user to keep entering guesses until they guess the random number correctly. Once they figure it, congratulate the user.
Hint: Make sure to generate the random number only once; otherwise, they will probably never finish.
Pseudocode:
seed random
set random to value between 1 and 1000
get guess from user
while guess does not equal random
if guess is less than random
print "Too Low" message
else if guess is greater than random
print "Too High" Message
get guess from user
end loop
print "congratulation" message
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