Question: xpand I need help with this program, can someone show me step by step how to do it. l need to expand ethe range to

xpand I need help with this program, can someone show me stepxpand I need help with this program, can someone show me step by step how to do it. l need to expand ethe range to be 1 to 20 and allow the user to get a maximum of 5 attempts to guess it. The game ends when the user has guessed the correct number (a win) or the number of incorrect guesses has reached 5 (a loss). At the end of each game, users should be told whether they won or lost. To make the game more interesting, the program should vary the wording of the messages that it outputs for winning, for losing, and for asking for another game. Create at least 2 different messages for each of these cases, and use random numbers to choose among them.

After printing out the win/loss messages, ask the user whether they want to play again and have them answer 'y' or 'n'. When the user quits with the 'n' answer, the program should output the total number of wins and losses. If they answer 'y', then a new random number should be generated and they will of course, have 5 attempts again to guess the number.

Here's some pseudo code that describes the outerloop of game control.

set answer to 'y'

while the answer is 'y' do the following steps

generate the random number

keep asking for a guess and comparing the guess to the computer's number until they win or have exceeded 5 guesses

print different messages out depending on whether they've won or lost

ask if they want to continue and set the response to the variable "answer"

They don't want to continue so print out the win/loss statistics

#include #include #include using namespace std; int main () int x; srand (time (NULL)) int y rand() % 20 +1; // this code will generate our random number //cout x; if (x= y) { cout

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!