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
Which list method allows elements in a sequence to be removed and added at either end of the structure?
Amanda [17]

Answer:

b) queue

Explanation:

Queue is also an abstract data type or a linear data structure, just like stack data structure, in which the first element is inserted from one end called the REAR(also called tail), and the removal of existing element takes place from the other end called as FRONT(also called head).

4 0
3 years ago
Read 2 more answers
When should the sponsor-monitor conduct the most detailed review of the study protocol with the site's study staff?
Likurg_2 [28]

Answer:

Site initiation visit is the correct answer.

Explanation:

Because the SIV is the sponsor-monitor which administers the detailed analysis of the site's study staff by the study protocol and it observes the process of the visite over a while that it take place after the visite of the site section. It also needed to set up the research site to administrates the analysis. So, that's why the following answer is true.

8 0
2 years ago
Apple Final Cut Pro is a digital video editing program that is available for Macs with OS X version 10.4 or later.
aniked [119]
That's actually true lol

3 0
3 years ago
Read 2 more answers
TQ Artificial Intelligence (AI)
dybincka [34]
Ask Elon Musk he knows
8 0
2 years ago
Which tool lets you increase the view, but not the size, of text, images, and other content?
blagie [28]
Use ctrl + or - or if in microsoft word, use the zoom tool
7 0
3 years ago
Other questions:
  • Briefly describe "SoftwareEngineering Framework". Do provide examples and diagrams wherenecessary.
    15·1 answer
  • What will be returned when the following SQL statement is executed?
    5·2 answers
  • When the packet leaves the router, which source and destination ip addresses will be contained in the packet?
    9·1 answer
  • Leonardo is having difficulty accessing the course website. he should contact the for assistance. (points:1)
    13·1 answer
  • In addition to format commands that are found in the ribbon, which option is available for more extensive formatting?
    11·1 answer
  • An alteration threat violates information integrity. <br> a. True <br> b. False
    13·1 answer
  • Which symbol is used for an assignment statement in a flowchart?
    13·1 answer
  • Which of the following statements is correct? User data cannot be combined and shared among authorized users. In a nondatabase,
    6·1 answer
  • How is distributed ledger technology (DLT) used in a blockchain?
    8·1 answer
  • What do you mean by computer ethics?​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!