Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem A: Number guessing game (20 points) Write a C++ program to do the following number guessing game. First, the computer should ask you to

image text in transcribedimage text in transcribed

Problem A: Number guessing game (20 points) Write a C++ program to do the following number guessing game. First, the computer should ask you to enter a "seed" value (see below). Then pick a random number from 1 to 9 without telling you the number. You get three chances to try and guess the number the computer picked. After you make one of your guesses, the computer should tell you one of the following statements: 1. "Close!" if you are within 1 of correct answer. 2. "Too low!" if you are below the number and not within 1. 3. Too high! if you are above the number and not within 1. 4. "Correct!" if you guessed the number exactly. If the player has not guessed the correct number after 3 tries, inform the player that they lost the game, tell them the correct answer and end the program. If the user correctly guesses the number("Correct! above), end the program. Important: Make sure your first lines of code in main() are as shown below to ask for the seed and setup the random number (i.e. variable "random"): int seed; cout > seed; srand (seed); int random = rand() % 9+1; If you do not follow this process, or generate a random number in a different way, you will probably not pass the test cases. You should also add this include at the top: #include Example 1 (user input is underlined): Enter seed: What is your guess? Too low! What is your guess? Too low! What is your guess? Close! You lost, the number was 8 Example 2 (user input is underlined): Enter seed: What is your guess? Close! What is your guess? Correct! Example 3 (user input is underlined): Enter seed: What is your guess? Too high! What is your guess? Too low! What is your guess? 999999999 Too high! You lost, the number was 7

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

More Books

Students also viewed these Databases questions

Question

Locate the centroid of the solid dz = a (a-) 2a

Answered: 1 week ago