
Write a C++ program proj1.cpp that lets the user or the computer play a guessing game. The computer randomly picks a number between 1 and 100, and then for each guess the user or computer makes, the computer informs the user whether the guess was too high or too low. The program should start a new guessing game when the correct number is selected to end this run (see the sample run below).
Here is a sample run of the program:
Would you like to (p)lay or watch the (c)omputer play?
p
Enter your guess in between 1 and 100.
45
Sorry, your guess is too low, try again.
Enter your guess in between 1 and 100.
58
Sorry, your guess is too low, try again.
Enter your guess in between 1 and 100.
78
Sorry, your guess is too high, try again.
Enter your guess in between 1 and 100.
67
Sorry, your guess is too low, try again.
Enter your guess in between 1 and 100.
70
Sorry, your guess is too high, try again.
Enter your guess in between 1 and 100.
68
Sorry, your guess is too low, try again.
Enter your guess in between 1 and 100.
69
Congrats, you guessed the correct number, 69.
Would you like to (p)lay or watch the (c)omputer play or (q)uit?
c
The computer's guess is 50.
Sorry, your guess is too high, try again.
The computer's guess is 25.
Sorry, your guess is too high, try again.
The computer's guess is 13.
Sorry, your guess is too low, try again.
The computer's guess is 19.
Sorry, your guess is too high, try again.
The computer's guess is 16.
Sorry, your guess is too low, try again.
The computer's guess is 17.
Congrats, you guessed the correct number, 17.
Would you like to (p)lay or watch the (c)omputer play or (q)uit?
q
Press any key to continue

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 6 images

- Hello, This is part of my hangman simulation in C++. If you compile and run it and type "Easy," the code should run. If you run it though, the body of the hangman doesn't align when you guess wrong. Could you help me with that and implement an if statement to repeat the program if user wants to play again? #include <iostream> #include <cstdlib> #include <ctime> #include <string> #include <iomanip>using namespace std; const int MAX_TRIES = 5;char answer; int letterFill(char, string, string&); int main() { string name; char letter; int num_of_wrong_guesses = 0; string word; srand(time(NULL)); // ONLY NEED THIS ONCE! // welcome the user cout << "\n\nWelcome to hangman!! Guess a fruit that comes into your mind."; // Ask user for for Easy, Average, Hard string level; cout << "\nChoose a LEVEL(E - Easy, A - Average, H - Hard):" << endl; cin >> level; // compare level if (level == "Easy") {//put all the string inside…arrow_forwardWrite a program in C++ which adds, subtracts, multiplies, divides and performs exponentiation on two specific numbers. The two numbers should be entered by the user. Each output should include a string describing what the numerical output is being displayed. Use the if-else-if ladder so that the user is able to select which mathematical function to perform. Make sure the program has a neat menu for the user to use to select their choice. Also, avoid having the computer perform a division by zero if the user attempts it by outputting a warning message in its place (use an if-else statement). Include your C++ source code as well as the output of your program in your submissionarrow_forwardin c++arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





