SlideShare uma empresa Scribd logo
1 de 1
Baixar para ler 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.

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

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
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
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
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
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
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 

Último (20)

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
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
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Ữ Â...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
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
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 

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.