Computers and Technology
Computers and Technology, 01.11.2019 02:31, Bubba06

Write a program that plays a guessing game with the user. specifically, your program should randomly pick a number between 1 and 100. then, ask the user for a guess. you should detect and tell the user if the guess is not a valid guess. otherwise, tell the user their guess was too high or too low. the program should continue to prompt the user for new guesses until they get the correct number, telling them each time if the guess was too high or too low or invalid.

you have been supplied code to pick a random number between 1 and 100 each time you run your program. here are a couple development/debugging strategies for this "target" variable:

print out the random number, to make sure your program is acting correctly – remember to remove/comment this before running unit tests/submitting.

temporarily set the random "seed" to a value, which will have the effect of always choosing the same random number – the unit tests have fixed seeds that you can use with known outcomes.

temporarily set the "target" variable to a fixed number, so you can test to see how your program responds in different testing situations.

here’s a sample run of a working version of the program:

enter your guess (between 1 and 100): 50

too high!

enter your guess (between 1 and 100): 0

invalid guess, try again!

enter your guess (between 1 and 100): 101

invalid guess, try again!

enter your guess (between 1 and 100): 25

too high!

enter your guess (between 1 and 100): 12

too high!

enter your guess (between 1 and 100): 6

too high!

enter your guess (between 1 and 100): 3

too low!

enter your guess (between 1 and 100): 4

too low!

enter your guess (between 1 and 100): 5

you win!

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:00, Geo777
Suppose an astronomer discovers a large, spherical-shaped body orbiting the sun. the body is composed mostly of rock, and there are no other bodies sharing its orbit. what is the best way to categorize this body? a. planet b. moon c. comet d. asteroid
Answers: 1
image
Computers and Technology, 23.06.2019 21:00, kkpsmith
Alcohol’s affects on the cornea and lens of the eye make it more difficult
Answers: 1
image
Computers and Technology, 24.06.2019 08:10, anthonysutton82
Where are american poets found in the dewey decimal system
Answers: 1
image
Computers and Technology, 24.06.2019 14:00, makaylahunt
Text or graphics that print at the bottom of every page are called footings footers headers headings
Answers: 1
Do you know the correct answer?
Write a program that plays a guessing game with the user. specifically, your program should randomly...

Questions in other subjects:

Konu
Mathematics, 28.01.2021 01:00
Konu
Mathematics, 28.01.2021 01:00
Konu
Mathematics, 28.01.2021 01:00