SlideShare a Scribd company logo
1 of 1
Download to read offline
Assignment 2a [20 points]A guessing game
Among other possibilities, algorithms developed using repetition control structures such as loops
can be used to generate properly formatted output of various types of intelligence tests.
Write a program 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 (user input is in bold):
The strategy that the program will use to make guesses is similar to what is often called a "binary
search". (Although the binary search was reviewed earlier in the Gaddis Chapter 8 in the context
of arrays, if you do not remember what a binary search is, or don't understand its connection here,
just ignore it. It is mentioned here in case it is helpful.)
The strategy 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
You must also (1) display a count of the number of tries the algorithm took based on user input to
determine the number and (2) provide the user the opportunity to play the game again or quit.
Be sure to use proper program formatting, meaningful variable identifier names and appropriate
prompts to the user in your code. No specific input validation routine is needed. The output should
be clear and formatted neatly.
(Note: In this program the Human user is thinking of a number at random in the range of 0 to 100
during each program run of this assignment. You may want to review how the computer can also
generate a random number in a range (see guess.cpp or guess2.cppLinks to an external site. ) for
implementation purposes when writing programs that require the Human user instead guessing
the number).
C++ Please.

More Related Content

Similar to Assignment 2a 20 pointsA guessing game Among other possib.pdf

Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning materialArthyR3
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docxwilcockiris
 
CSP1150D Programming Principles
CSP1150D Programming PrinciplesCSP1150D Programming Principles
CSP1150D Programming PrinciplesNicole Valerio
 
Industrial Control System Assignment Help|25% Online Assignment Help
Industrial Control System Assignment Help|25% Online Assignment HelpIndustrial Control System Assignment Help|25% Online Assignment Help
Industrial Control System Assignment Help|25% Online Assignment HelpNicole Valerio
 

Similar to Assignment 2a 20 pointsA guessing game Among other possib.pdf (9)

Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
Visual Logic Project - 1
Visual Logic Project - 1Visual Logic Project - 1
Visual Logic Project - 1
 
17 Jo P May 08
17 Jo P May 0817 Jo P May 08
17 Jo P May 08
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
 
Beekman5 std ppt_13
Beekman5 std ppt_13Beekman5 std ppt_13
Beekman5 std ppt_13
 
Java Practice Set
Java Practice SetJava Practice Set
Java Practice Set
 
CSP1150D Programming Principles
CSP1150D Programming PrinciplesCSP1150D Programming Principles
CSP1150D Programming Principles
 
Industrial Control System Assignment Help|25% Online Assignment Help
Industrial Control System Assignment Help|25% Online Assignment HelpIndustrial Control System Assignment Help|25% Online Assignment Help
Industrial Control System Assignment Help|25% Online Assignment Help
 
If switch structure
If switch structureIf switch structure
If switch structure
 

More from kksrivastava1

Assume that there exists a bestfirst search algorithm in wh.pdf
Assume that there exists a bestfirst search algorithm in wh.pdfAssume that there exists a bestfirst search algorithm in wh.pdf
Assume that there exists a bestfirst search algorithm in wh.pdfkksrivastava1
 
Assume that there are 5 processes P0 through P4 and 4 type.pdf
Assume that there are 5 processes P0 through P4 and 4 type.pdfAssume that there are 5 processes P0 through P4 and 4 type.pdf
Assume that there are 5 processes P0 through P4 and 4 type.pdfkksrivastava1
 
Assume that there are 5 processes PO through P4 and 4 type.pdf
Assume that there are 5 processes PO through P4 and 4 type.pdfAssume that there are 5 processes PO through P4 and 4 type.pdf
Assume that there are 5 processes PO through P4 and 4 type.pdfkksrivastava1
 
Assume that SLL is a singly linked list with the head node .pdf
Assume that SLL is a singly linked list with the head node .pdfAssume that SLL is a singly linked list with the head node .pdf
Assume that SLL is a singly linked list with the head node .pdfkksrivastava1
 
Assume that i is in t0 register x is in f0 register the .pdf
Assume that i is in t0 register x is in f0 register the .pdfAssume that i is in t0 register x is in f0 register the .pdf
Assume that i is in t0 register x is in f0 register the .pdfkksrivastava1
 
Assume that a simple random sample has been selected and tes.pdf
Assume that a simple random sample has been selected and tes.pdfAssume that a simple random sample has been selected and tes.pdf
Assume that a simple random sample has been selected and tes.pdfkksrivastava1
 
Assume that a security model is needed to protect informatio.pdf
Assume that a security model is needed to protect informatio.pdfAssume that a security model is needed to protect informatio.pdf
Assume that a security model is needed to protect informatio.pdfkksrivastava1
 
Assume that 352 of people have sleepwalked Assume that in.pdf
Assume that 352 of people have sleepwalked Assume that in.pdfAssume that 352 of people have sleepwalked Assume that in.pdf
Assume that 352 of people have sleepwalked Assume that in.pdfkksrivastava1
 
assume Assume fn4n01gn10lognhn2npn3logn i.pdf
assume Assume fn4n01gn10lognhn2npn3logn i.pdfassume Assume fn4n01gn10lognhn2npn3logn i.pdf
assume Assume fn4n01gn10lognhn2npn3logn i.pdfkksrivastava1
 
Assume an organization is planning to move a significant IT .pdf
Assume an organization is planning to move a significant IT .pdfAssume an organization is planning to move a significant IT .pdf
Assume an organization is planning to move a significant IT .pdfkksrivastava1
 
Assume a singly linkedlist List class of nodes sorted by .pdf
Assume a singly linkedlist List class of nodes sorted by .pdfAssume a singly linkedlist List class of nodes sorted by .pdf
Assume a singly linkedlist List class of nodes sorted by .pdfkksrivastava1
 
Assume a firm has earnings before depreciation and taxes of .pdf
Assume a firm has earnings before depreciation and taxes of .pdfAssume a firm has earnings before depreciation and taxes of .pdf
Assume a firm has earnings before depreciation and taxes of .pdfkksrivastava1
 
Assignment4 Assignment 4 Hashtables In this assignment we w.pdf
Assignment4 Assignment 4 Hashtables In this assignment we w.pdfAssignment4 Assignment 4 Hashtables In this assignment we w.pdf
Assignment4 Assignment 4 Hashtables In this assignment we w.pdfkksrivastava1
 
Assignment Overview Over twothirds of Americans are conside.pdf
Assignment Overview Over twothirds of Americans are conside.pdfAssignment Overview Over twothirds of Americans are conside.pdf
Assignment Overview Over twothirds of Americans are conside.pdfkksrivastava1
 
Associativity Left to right 1 Show the order of evaluatio.pdf
Associativity Left to right 1 Show the order of evaluatio.pdfAssociativity Left to right 1 Show the order of evaluatio.pdf
Associativity Left to right 1 Show the order of evaluatio.pdfkksrivastava1
 
ASSIGNMENT OI a The IASBs Framework for the Preparation a.pdf
ASSIGNMENT OI a The IASBs Framework for the Preparation a.pdfASSIGNMENT OI a The IASBs Framework for the Preparation a.pdf
ASSIGNMENT OI a The IASBs Framework for the Preparation a.pdfkksrivastava1
 
Assignment is a case essay and requires you to obtain suffic.pdf
Assignment is a case essay and requires you to obtain suffic.pdfAssignment is a case essay and requires you to obtain suffic.pdf
Assignment is a case essay and requires you to obtain suffic.pdfkksrivastava1
 
Assignment 4 Class Petromyzontida 10 List three features o.pdf
Assignment 4 Class Petromyzontida 10 List three features o.pdfAssignment 4 Class Petromyzontida 10 List three features o.pdf
Assignment 4 Class Petromyzontida 10 List three features o.pdfkksrivastava1
 
Assign the ICD10CM codes to diagnosis and conditions and.pdf
Assign the ICD10CM codes to diagnosis and conditions and.pdfAssign the ICD10CM codes to diagnosis and conditions and.pdf
Assign the ICD10CM codes to diagnosis and conditions and.pdfkksrivastava1
 
Assigned Topic Alzheimers disease Case study Create a b.pdf
Assigned Topic Alzheimers disease Case study  Create a b.pdfAssigned Topic Alzheimers disease Case study  Create a b.pdf
Assigned Topic Alzheimers disease Case study Create a b.pdfkksrivastava1
 

More from kksrivastava1 (20)

Assume that there exists a bestfirst search algorithm in wh.pdf
Assume that there exists a bestfirst search algorithm in wh.pdfAssume that there exists a bestfirst search algorithm in wh.pdf
Assume that there exists a bestfirst search algorithm in wh.pdf
 
Assume that there are 5 processes P0 through P4 and 4 type.pdf
Assume that there are 5 processes P0 through P4 and 4 type.pdfAssume that there are 5 processes P0 through P4 and 4 type.pdf
Assume that there are 5 processes P0 through P4 and 4 type.pdf
 
Assume that there are 5 processes PO through P4 and 4 type.pdf
Assume that there are 5 processes PO through P4 and 4 type.pdfAssume that there are 5 processes PO through P4 and 4 type.pdf
Assume that there are 5 processes PO through P4 and 4 type.pdf
 
Assume that SLL is a singly linked list with the head node .pdf
Assume that SLL is a singly linked list with the head node .pdfAssume that SLL is a singly linked list with the head node .pdf
Assume that SLL is a singly linked list with the head node .pdf
 
Assume that i is in t0 register x is in f0 register the .pdf
Assume that i is in t0 register x is in f0 register the .pdfAssume that i is in t0 register x is in f0 register the .pdf
Assume that i is in t0 register x is in f0 register the .pdf
 
Assume that a simple random sample has been selected and tes.pdf
Assume that a simple random sample has been selected and tes.pdfAssume that a simple random sample has been selected and tes.pdf
Assume that a simple random sample has been selected and tes.pdf
 
Assume that a security model is needed to protect informatio.pdf
Assume that a security model is needed to protect informatio.pdfAssume that a security model is needed to protect informatio.pdf
Assume that a security model is needed to protect informatio.pdf
 
Assume that 352 of people have sleepwalked Assume that in.pdf
Assume that 352 of people have sleepwalked Assume that in.pdfAssume that 352 of people have sleepwalked Assume that in.pdf
Assume that 352 of people have sleepwalked Assume that in.pdf
 
assume Assume fn4n01gn10lognhn2npn3logn i.pdf
assume Assume fn4n01gn10lognhn2npn3logn i.pdfassume Assume fn4n01gn10lognhn2npn3logn i.pdf
assume Assume fn4n01gn10lognhn2npn3logn i.pdf
 
Assume an organization is planning to move a significant IT .pdf
Assume an organization is planning to move a significant IT .pdfAssume an organization is planning to move a significant IT .pdf
Assume an organization is planning to move a significant IT .pdf
 
Assume a singly linkedlist List class of nodes sorted by .pdf
Assume a singly linkedlist List class of nodes sorted by .pdfAssume a singly linkedlist List class of nodes sorted by .pdf
Assume a singly linkedlist List class of nodes sorted by .pdf
 
Assume a firm has earnings before depreciation and taxes of .pdf
Assume a firm has earnings before depreciation and taxes of .pdfAssume a firm has earnings before depreciation and taxes of .pdf
Assume a firm has earnings before depreciation and taxes of .pdf
 
Assignment4 Assignment 4 Hashtables In this assignment we w.pdf
Assignment4 Assignment 4 Hashtables In this assignment we w.pdfAssignment4 Assignment 4 Hashtables In this assignment we w.pdf
Assignment4 Assignment 4 Hashtables In this assignment we w.pdf
 
Assignment Overview Over twothirds of Americans are conside.pdf
Assignment Overview Over twothirds of Americans are conside.pdfAssignment Overview Over twothirds of Americans are conside.pdf
Assignment Overview Over twothirds of Americans are conside.pdf
 
Associativity Left to right 1 Show the order of evaluatio.pdf
Associativity Left to right 1 Show the order of evaluatio.pdfAssociativity Left to right 1 Show the order of evaluatio.pdf
Associativity Left to right 1 Show the order of evaluatio.pdf
 
ASSIGNMENT OI a The IASBs Framework for the Preparation a.pdf
ASSIGNMENT OI a The IASBs Framework for the Preparation a.pdfASSIGNMENT OI a The IASBs Framework for the Preparation a.pdf
ASSIGNMENT OI a The IASBs Framework for the Preparation a.pdf
 
Assignment is a case essay and requires you to obtain suffic.pdf
Assignment is a case essay and requires you to obtain suffic.pdfAssignment is a case essay and requires you to obtain suffic.pdf
Assignment is a case essay and requires you to obtain suffic.pdf
 
Assignment 4 Class Petromyzontida 10 List three features o.pdf
Assignment 4 Class Petromyzontida 10 List three features o.pdfAssignment 4 Class Petromyzontida 10 List three features o.pdf
Assignment 4 Class Petromyzontida 10 List three features o.pdf
 
Assign the ICD10CM codes to diagnosis and conditions and.pdf
Assign the ICD10CM codes to diagnosis and conditions and.pdfAssign the ICD10CM codes to diagnosis and conditions and.pdf
Assign the ICD10CM codes to diagnosis and conditions and.pdf
 
Assigned Topic Alzheimers disease Case study Create a b.pdf
Assigned Topic Alzheimers disease Case study  Create a b.pdfAssigned Topic Alzheimers disease Case study  Create a b.pdf
Assigned Topic Alzheimers disease Case study Create a b.pdf
 

Recently uploaded

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 

Recently uploaded (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

Assignment 2a 20 pointsA guessing game Among other possib.pdf

  • 1. Assignment 2a [20 points]A guessing game Among other possibilities, algorithms developed using repetition control structures such as loops can be used to generate properly formatted output of various types of intelligence tests. Write a program 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 (user input is in bold): The strategy that the program will use to make guesses is similar to what is often called a "binary search". (Although the binary search was reviewed earlier in the Gaddis Chapter 8 in the context of arrays, if you do not remember what a binary search is, or don't understand its connection here, just ignore it. It is mentioned here in case it is helpful.) The strategy 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 You must also (1) display a count of the number of tries the algorithm took based on user input to determine the number and (2) provide the user the opportunity to play the game again or quit. Be sure to use proper program formatting, meaningful variable identifier names and appropriate prompts to the user in your code. No specific input validation routine is needed. The output should be clear and formatted neatly. (Note: In this program the Human user is thinking of a number at random in the range of 0 to 100 during each program run of this assignment. You may want to review how the computer can also generate a random number in a range (see guess.cpp or guess2.cppLinks to an external site. ) for implementation purposes when writing programs that require the Human user instead guessing the number). C++ Please.