Introduction to Computer Science:
Assignment 26:  Binary Search
 Sewickley Academy, 2000-2001

See Course Home Page.
 
Date Assigned: Wed Dec-13
Date Due: Thu Dec-14

Note:  You must work alone on this assigment.  Also, as usual, please have your program running and ready for grading at the start of class tomorrow.

Further note:  we will review how to Goedelize rectangles tomorrow in class, and tomorrow night's assignment will be to Goedelize rectangles and 3dPoints.

Tonight's assignment is a twist on Binary Search.  Write a program with the following behavior (recall that user input is underlined):

BE SURE YOUR PROGRAM'S OUTPUT IS *EXACTLY* AS THIS:

Number Guesser:  This program guesses a number that you pick.

Pick a number between 0 and 1000.

Your number is between 0 and 1000, so I guess it is 500.

Am I too low (-1), just right (0), or too high (1): -1

Ok.  Your number is between 501 and 1000, so I guess it is 750.

Am I too low (-1), just right (0), or too high (1): 1

Ok.  Your number is between 501 and 749, so I guess it is 625.

Am I too low (-1), just right (0), or too high (1): 0

Woohoo! I guessed your number in only 3 guesses!!!


See Course Home Page.