Question: 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

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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!