Question
Program Language: C++ Objectives: 1.Use if statements and a switch statement 2. Use random number generatros 3. Use multiple do while loops Instructions: This is
Program Language: C++
Objectives:
1.Use if statements and a switch statement
2. Use random number generatros
3. Use multiple do while loops
Instructions:
This is a lot like Lab 4 but you must add more conditions and two loops to the program.
You are to design and implement an application that plays the Hi-Lo guessing game with numbers. The program should start by picking a random number between 1 and 100 (inclusive). After that, it should repeatedly prompt the user to guess the number.
On each guess, report to the user whether he or she guessed correct. If not, report whether the guess was too high, too low, out of range (less than 1 or greater than 100).
The user can choose -1 during a game to quit the current game early. If they decide to do this, please display that as the result of his or her guess instead of to low/out of range.
Continue accepting guesses until the user guesses correctly or chooses to quit. Make sure you count the number of guesses and report that value when the user guesses correctly or chooses to quit the game. If the user quits a game, just print that he or she has quit after so many guesses.
At the end of each game (by quitting or a correct guess), prompt the user to determine whether he or she wants to play again. Continue playing games until the user chooses to stop. You can use -1 for this quit response. You can also use a letter like Y or N or even use a String like yes or no. Consider using two do loops to solve this problem although there are many other correct ways if you prefer another solution.
Run:
Be sure to test all possibilities in your test run:
Run at least two continuous games, in which you prove the counter of guesses is resetting.
Then run a game in which the user exits early with a -1. Make sure you still print the count of guesses; do not count the -1 as a guess.
Then run a game to completion but check for each of the out of range cases. A guess that is (< -1, == 0, and finally > 100)
Keep running games until user decides to quit the whole program.
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