Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Programming Build a Guessing Game Program: >- Write a program to implement t

ID: 3688121 • Letter: C

Question

C++ Programming

Build a Guessing Game Program:

>- Write a program to implement the Number Guessing Game. The main method should loop as long as the player wants to play the game again.

>- Write a function called PlayGame(). In this function write the code to play the game. In the game the computer chooses a random number between 1 and 100, and the player tries to guess the number in as few attempts as possible. Each time the player enters a guess, the computer tells the player whether the guess is too high, too low, or right. Once the player guesses the number, that game is over. Keep track of how many guesses it takes the player to get the number correct.

>- The main function should use an array to keep track of how many attempts it takes the player to guess the random number each time they play the game. When the player decides to exit the game, print out the results of each game and the average number of guesses it took this player.

>- As the game ends, write the average number of guesses it took this player to guess the random numbers to a file. The next time they play, read in the avg from the last time they played, and if the current game avg is better than the one in the file print -> “Congratulations you have improved your score since the last time you played”. If not print -> “Your score was better last time you played than today”.

Explanation / Answer

#include #include #include int main(void) { srand(time(NULL)); // To not have the same numbers over and over again. while(true) { // Main loop. // Initialize and allocate. int number = rand() % 99 + 2; // System number is stored in here. int guess; // User guess is stored in here. int tries = 0; // Number of tries is stored here. char answer; // User answer to question is stored here. //std::cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote