Question
Problem Statement Construct a c++ program in which you have selected a number between 0 and 100, inclusively (the number is greater than or equal
Problem Statement Construct a c++ program in which you have selected a number between 0 and 100, inclusively (the number is greater than or equal to zero and less than or equal to 100). The program should prompt the user to guess the number that you have selected. If the user guesses the number that you have selected, then the program should output the message, Congratulations you have guessed the number followed by the actual number that you selected. Otherwise, the program should check whether the guess the user provided is less than the actual number that you selected or greater than the number that you selected. If the guess is less than the selected number, the program should output the message. Your guess is lower than the selected number. If the guess is higher than the selected number, your program should output the message, Your guess is higher than the selected number.
Your program should limit the number of tries that the user can guess the number to a maximum of five. The user should also have the option to stop guessing before the 5th attempt to guess your selected number.
Your program should begin with the following output message:
Welcome to (your name) Guessing Game. Please enter a number between 0 and 100 inclusively. You will have a maximum of 5 attempts to guess the number. After the first guess, if you do not get it correct, you will be prompted to indicated whether you would like to continue the game or quit. If you enter y or Y, you will be prompted to enter your new guess.
Once the user has made an initial guess that is not correct, the program should prompt the user with the following output:
If guess is lower
Your guess is lower than the selected number.
Please enter Y or y for yes to continue guessing and enter N or n to exit the game.
If guess is higher
Your guess is higher than the selected number.
Please enter Y or y for yes to continue guessing and enter N or n to exit the game.
If the user indicates that he/she wants to continue guessing, the user should be prompted with the outputted
message, Please enter a number between 0 and 100 inclusively. You have (some number) of remaining tries. The user will then enter the guess that will be read by the program.
The game should stop once the user has made the correct guess, the user has indicated that he/she wants to stop guessing, or once the user has tried five times to guess the number. Upon reaching the end of the game, your program should output the following message if the user did not win the game, Sorry you lost the game. Better luck next time.
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