Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with this c++ code please. Write a C++ program to implement the Number Guessing Game. In this game, the computer chooses a random number

Help with this c++ code please.
Write a C++ program to implement the Number Guessing Game. In this game, the computer chooses a random number between 1 and 100. The player tries to guess the number in 7 or less attempts. Each time the player enters a guess, the computer will display a HINT to either guess HIGHER or LOWER if they do not guess the random number. Once the player guesses the number, congratulate the player and prompt the user if they would like to play the game again.
Suggested Pseudocode (You may design the program yourself or you can use this Pseudocode. You do NOT have to use functions.)
Initialize variables for the random number, the guessed number, the number of attempts, and the repeat option
do{
Set attempts equal to 0 in case player wants to play game again
Randomly generate a number between 1 and 100 (srand() and rand() )
Display Guess My Number Game
While the guessed number does not equal the random number AND all 7 attempts have not been used
Prompt the user to enter a number between 1 and 100
Add one to the number of attempts
if (guessed number is greater than the random number)
Display a Hint to Guess LOWER
else if (guessed number is less than the random number)
Display a Hint to Guess HIGHER
else
Display Congratulations, you guessed the (random number) in (how many attempts were used)
if the guessed number does not equal the random number
Display Sorry, you did not guess the number
Ask the player if they would like to play the game again?
}while the player wants to play the game, go to the beginning of the loop to play again
image text in transcribed
AMPLE OUTPUT: Enter a guess hetteen 1 and 1a JNI: Guess LOWER! ter a pess letten 1 10:3 HINT: Guess HIGER! HINT: Guess WER! Enter a guess hetaeen 1 and 30 IKI: Guess HIGHER! Enter a guess leteen 1 and 10 JNI: Guest HIGHER! Enter a guess letreen 1 10 HINT: Guess WER! ntera gets hetween 1 and angatualtions!!ou guessed the urler in guesses! ater a ness letneen 1 10:3 HINT: Guess HIGER! Enter letueen 1 and 1a :S Guess HIGHER! ater a guest heteen 1 and 6 INT: Guess HIGER! Enter a ness letneen 1 100 Guess HIGER! nter a guess letneen 1 and 10:9 Enter a guess hetween 1 and 10 INT: Guest HIGER! Enter a guess letreen 1 ad 10 12 INT: Guess HIGER! urry did not guess the nuber! Nould like play again(1 or Efe Ko)? ress any key to tontinue 11

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions