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, 21.06.2019 17:20
The liang book has an example called which is a javafx application that reads the javabook database using a preparedstatement object. using it as a guide, create a similar application called findbooks. it will read a list of authors from the bookdb created in problem 1 and display them in a listview. if the user selects an author, it should display the author's book titles in a textarea.
Answers: 2
question
Computers and Technology, 22.06.2019 03:00
Which action describes an aspect of technological design?
Answers: 1
question
Computers and Technology, 22.06.2019 05:10
Suppose we have a byte addressable computer that has a 32-byte cache with 8 bytes per block. the memory address is 8 bits long. the system accesses memory addresses (in hex) in this exact order: 6e, b9, 17, e0, 4e, 4f, 50, 91, a8, ab, ad, 93, and 94. (a) assuming the cache is direct mapped, what memory addresses will be in cache block 2 after the last address has been accessed? (b) assuming the cache is direct mapped, what is the hit ratio for the entire memory reference sequence given, assuming the cache is initially empty? (c) assuming the cache is 2-way set associative with a lru replacement policy, what is the hit ratio?
Answers: 3
question
Computers and Technology, 23.06.2019 13:00
Which one of the following voltages should never be measured directly with a vom? a. 1200 v b. 500 v c. 800 v d. 100v
Answers: 2
You know the right answer?
Write a program that plays a guessing game with the user. specifically, your program should randomly...
Questions
question
Mathematics, 13.09.2021 15:00
question
Mathematics, 13.09.2021 15:10
question
Mathematics, 13.09.2021 15:10
Questions on the website: 13722367