Question: Write a Guessing Game C + + #include #include #include using namespace std; int main ( ) { srand ( time ( 0 ) )
Write a Guessing Game C
#include
#include
#include
using namespace std;
int main
srand time;
char choice;
int range, guessedNumber Totaltries ;
cout "Welcome to the guessing game!
;
cout "I'll choose a number between and a limit of your choice,
"and you guess what it is
;
cout "How high would you like the guessing range to be;
cin range;
int bestscore ;
do
int number rand range ;
cout Im thinking of a number! What is it;
cin guessedNumber;
while guessedNumber number
if guessedNumber number
cout "Woopsies that's too low. Try again: ;
cin guessedNumber;
else if guessedNumber number
cout "Dang, that's too high. Try again: ;
cin guessedNumber;
Totaltries ;
cout "You guessed it It took Totaltries tries.
;
Totaltries ;
if bestscore Totaltries
bestscore Totaltries;
cout Youve set a new record for the lowest number of guesses!
;
cout "Would you like to play again? YN: ;
cin choice;
while choice Y choice y;
return ;
Instead of let the user choose the upper guessing limit
Keep track of the number of tries that it took for the user to get the right answer and
display that to them once theyve guessed the correct answer.
Add the ability for the user to play again without having to restart the game.
Keep track of an overall low score the lower the number of guesses, the better If the
user beats the current best score, display a message to them telling them so and set the
overall low score to be the number of guesses it took from that round.
How can I fix my code?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
