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

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:20
Write a program called assignment3 (saved in a file assignment3.java) that computes the greatest common divisor of two given integers. one of the oldest numerical algorithms was described by the greek mathematician, euclid, in 300 b.c. it is a simple but very e↵ective algorithm that computes the greatest common divisor of two given integers. for instance, given integers 24 and 18, the greatest common divisor is 6, because 6 is the largest integer that divides evenly into both 24 and 18. we will denote the greatest common divisor of x and y as gcd(x, y). the algorithm is based on the clever idea that the gcd(x, y) = gcd(x ! y, y) if x > = y and gcd(x, y) = gcd(x, y ! x) if x < y. the algorithm consists of a series of steps (loop iterations) where the “larger” integer is replaced by the di↵erence of the larger and smaller integer. this continues until the two values are equal. that is then the gcd.
Answers: 3
question
Computers and Technology, 23.06.2019 00:00
Which is the correct sequence of steps to set up a document in landscape orientation? a. select page setup from the file menu. then click the margins tab and select landscape. b. select page setup from the edit menu. then click the margins tab and select landscape. c. select page setup from the insert menu. then click the margins tab and select landscape. d. select page setup from the format menu. then click the margins tab and select landscape
Answers: 1
question
Computers and Technology, 23.06.2019 13:00
Donnie does not have powerpoint. which method would be best for elana to save and share her presentation as is? a pdf a doc an rtf a ppt
Answers: 3
question
Computers and Technology, 23.06.2019 21:00
Which set of steps will organize the data to only show foods with more than 100 calories and rank their sugar content from greatest to least?
Answers: 1
You know the right answer?
Write a program that plays a guessing game with the user. specifically, your program should randomly...
Questions
Questions on the website: 13722362