Write a C++ program with the following 2 functions that plays the game of “guess the number” as follows:  Function 1:  Generate the random number. Your program chooses the number to be guessed by selecting an integer at random in the range 1 to 1000.   Main: I have a number between 1 and 1000. Can you guess my number? Please type in your first guess. Function 2:  The user guesses. The program then displays the following: The player then types a first guess.  The program then responds with one of the following: 1.    Excellent! You guessed the number!  Otherwise     a. If the number of guesses is 10 or fewer, print “Either you know the secret or you got lucky!”   b. If the player guesses the number in 10 tries, then print “Ahah! You know the secret!”  c. If the player makes more than 10 guesses, then print, “You should be able to do better!”      If the player failed to guess the number: 1.    Too low. Try again. Or 2.    Too high. Try again. Followed by: Would you like to play again (y or n)? If the player’s guess is incorrect, you program should loop until the player finally gets the number right.  Your program should keep telling the player Too high or Too low to help the player “zero in” on the correct answer.  You must count the number of guesses the player makes The loop in Main: Followed by: Would you like to play again (y or n)? Your player must play this game at least 3 times.  You are not to run the program 3 times, you are to loop thru the program each time.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Write a C++ program with the following 2 functions that plays the game of “guess the number” as follows: 
Function 1:  Generate the random number. Your program chooses the number to be guessed by selecting an integer at random in the range 1 to 1000.  

Main:
I have a number between 1 and 1000.
Can you guess my number?
Please type in your first guess.
Function 2:  The user guesses.
The program then displays the following:
The player then types a first guess.  The program then responds with one of the following:
1.    Excellent! You guessed the number! 
Otherwise
    a. If the number of guesses is 10 or fewer, print “Either you know the secret or you got lucky!”  
b. If the player guesses the number in 10 tries, then print “Ahah! You know the secret!” 
c. If the player makes more than 10 guesses, then print, “You should be able to do better!”
    
If the player failed to guess the number:
1.    Too low. Try again.
Or
2.    Too high. Try again.
Followed by: Would you like to play again (y or n)?

If the player’s guess is incorrect, you program should loop until the player finally gets the number right.  Your program should keep telling the player Too high or Too low to help the player “zero in” on the correct answer.  You must count the number of guesses the player makes
The loop in Main:
Followed by: Would you like to play again (y or n)?
Your player must play this game at least 3 times.  You are not to run the program 3 times, you are to loop thru the program each time.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY