1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sloan [31]
3 years ago
7

Write a program in c++ that plays a number guessing game with a Human user. The Human user will think of a number between 1 and

100, inclusive. The program will make guesses and the user will tell the program to guess higher or lower. A sample run of the program might look like this: Ready to play (y/n)? y Think of a number between 1 and 100. My guess is 50. Enter 'l' if your number is lower, 'h' if it is higher, 'c' if it is correct: h My guess is 75. Enter 'l' if your number is lower, 'h' if it is higher, 'c' if it is correct: h My guess is 88. Enter 'l' if your number is lower, 'h' if it is higher, 'c' if it is correct: l My guess is 81. Enter 'l' if your number is lower, 'h' if it is higher, 'c' if it is correct: c Great! Do you want to play again (y/n)? y Think of a number between 1 and 100. My guess is 50. Enter 'l' if your number is lower, 'h' if it is higher, 'c' if it is correct: l My guess is 25. Enter 'l' if your number is lower, 'h' if it is higher, 'c' if it is correct: h My guess is 37. Enter 'l' if your number is lower, 'h' if it is higher, 'c' if it is correct: c Great! Do you want to play again (y/n)? n The strategy that the program will use goes like this: Every time the program makes a guess it should guess the midpoint of the remaining possible values. Consider the first example above, in which the user has chosen the number 81: On the first guess, the possible values are 1 to 100. The midpoint is 50. The user responds by saying "higher" On the second guess the possible values are 51 to 100. The midpoint is 75. The user responds by saying "higher" On the third guess the possible values are 76 to 100. The midpoint is 88. The user responds by saying "lower" On the fourth guess the possible values are 76 to 87. The midpoint is 81. The user responds "correct" Additional Requirements The purpose of the assignment is to practice writing functions. Although it would be possible to write the entire program in the main function, your solution should be heavily structured. Most of the point penalties given on this assignment will be for not following the instructions below carefully. The main function must look exactly like this. Copy and paste this code into your file, and don't edit it: int main() { char response; cout > response; while (response == 'y') { playOneGame(); cout > response; } } The playOneGame() function should implement a complete guessing game on the range of 1 to 100. The lower and upper bounds of the range should be assigned to global named constants and then not used again in your code. In addition, you should implement the following helper functions to be invoked inside your playOneGame() function: void getUserResponseToGuess(int guess, char& result) The getUserResponseToGuess() function should prompt the user to enter 'h', 'l', or 'c' (as shown in the sample output). It should set its "result" parameter equal to whatever the user enters in response. It should do this ONE time, and should not do anything else. Note that printing the guess is part of the prompt. int getMidpoint(int low, int high) The getMidpoint() function should accept two integers, and it should return the midpoint of the two integers. If there are two values in the middle of the range then you should consistently chose the smaller of the two.
Computers and Technology
2 answers:
aniked [119]3 years ago
8 0

Answer:

the question is too long. dear

.mate

3241004551 [841]3 years ago
3 0
That’s too much to understand, could you make it more simple to read and understand?
You might be interested in
As a digital strategist, Jared wants to add something extra to his ads to give users more incentive to click and convert. He's c
nadya68 [22]

Answer:

A) Up to 15 characters in each.

Explanation:

Total characters he can use in each of these optional paths are up to 15 characters in each.

6 0
3 years ago
Which is a solution that represents the majority of VPNs on the market and is commonly referred to as a VPN appliance?
Dafna1 [17]

Answer:

Remote access VPN

Explanation:

The solution that represents the majority of VPN's on the markets and is commonly referred to as a VPN appliance is the Remote access VPN

A remote access VPN is a type of VPN  that  works by creating a virtual channel (appliance ) between different devices for the purpose of exchanging data in an encrypted form. although this Tunnel passes through the public internet the Data exchanged are only accessible by the devices connected via the tunnel only .

The remote access VPN  is mostly used to connect an employee to the company's network therefore it represent the majority of VPNs in the market.

3 0
3 years ago
What are the steps to configure user information in a document?
chubhunter [2.5K]

Answer:

file, properties, options, general

Explanation:

4 0
2 years ago
Read 2 more answers
The part of a computer that provides access to the internet
guapka [62]

Answer:

Modem

Explanation:

A modem is a device that converts your data into a relevant format so that it can be used in the transmitting process from one computer to another one.

3 0
2 years ago
1. Withdrawal occurs when alcohol is removed from the system after the brain has
Westkost [7]
Experienced it for an extended period of time.
4 0
2 years ago
Other questions:
  • If the test statistic for a small sample difference of means test is t* = 2.045, we could reject the Null Hypothesis at alpha =
    9·1 answer
  • By generating and delivering timely and relevant information supported by networks, _____ creates new opportunities for conducti
    15·1 answer
  • Internally, computers are constructed from circuitry that consists of small on/off switches. What is the most basic circuitry-le
    12·1 answer
  • Load the titanic sample dataset from the Seaborn library into Python using a Pandas dataframe, and visualize the dataset. Create
    10·1 answer
  • A computerized spreadsheet program is useful for
    6·2 answers
  • Write a program that continually prompts the user for an integer input until input is entered that is less than 0. Each input th
    9·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    12·2 answers
  • What happens if you create multiple accounts just to get points faster?
    6·1 answer
  • Which of these is a physical health benefit provided by playing team sports? A. a spiritual connection to others B. lower choles
    5·2 answers
  • An agile team has which two characteristics? (choose two. ).
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!