Answered step by step
Verified Expert Solution
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
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started