Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

******* C++ ********** Write a program named, hiLo .cpp . This program is a simple number guessing game that allows the user to guess a

******* C++ **********

Write a program named, hiLo.cpp. This program is a simple number guessing game that allows the user to guess a number between 1 and 100, inclusive. The game will start with the program automatically selecting a random, secret number for the user to attempt to guess. The textbook covers generating random numbers and demonstrates the seeding of the random number generator so that a different secret number is generated each time the user plays this game. Each time the user makes a guess, the game will respond by stating that the guess was either out of range, too high, too low, or correct. If the guess was too high or too low, then the range of values for the next guess narrows and is displayed in the prompt for the next guess. Each prompt must include the number of the next guess (which does not change when the guess is out of range) and the range of values in which the next guess should be. When a guess is valid but not correct, the range will get smaller. The range NEVER gets wider. If the guessed value is out of range, an error message is printed and that guess is not counted as a valid guess. At the end, once the secret number has been correctly guessed, the numbers of valid and out of range (or invalid) guesses are displayed. This final display telling the user that the number was correctly (and the counts) must be display outside the loop and after the loop, NOT inside the main loop. The main loop should iterate as long as the guess is not correct. Get the first guess before the loop and then only ONCE inside the loop, at the end of the loop body. When your program is executing, the console should look EXACTLY like the example execution log in this file. In this example execution log, notice the following: 1 - Every prompt for a guess contains the number of that guess and the min and max values for the range of that guess. 2 - The guess number does not increase when the guess is out of range. 3 - The boundaries of the range only get closer together as guesses are made; the range NEVER widens. 4 - Once the secret number is guessed, the program states how many valid and how many out of range guesses were made. 5 - After one round of the game is done, the user is given the option to play another round.

Finally, each time the program is executed, a diffferent list of secret numbers gets chosen. This happens if you have correctly seed the random number generator ONCE per execution. The seeding of the generator should be done before any of the loops and only once per program execution.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

LO2 Explain the major laws governing employee compensation.

Answered: 1 week ago