Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that plays a guessing game with the user. Specifically, your program should randomly pick a number between 1 and 10o. Then, ask

image text in transcribed

Write a program that plays a guessing game with the user. Specifically, your program should randomly pick a number between 1 and 10o. 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):e 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 Toolow Enter your guess (between 1 and 100): 5 You win! You have been supplied with JUnit tests for a set of lucky guesses (i.e. the user immediately guesses the right answer), lucky guesses starting with invalid guesses, and a full game, including both invalid and va

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago