This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: the class, your program should display: Seat 1, Seat 2, Seat 3, Seat 4, Seat 5 Seat 1, Seat 2, Seat 3 Guess in 20 Questions with a Twist Write a program that generates a random integer r between 1 and 20. Then it prompts the user to guess a value. At each step, your program should compare the user-entered value with r and announce: “larger, smaller, or You win!” if the guessed value is larger, smaller or equal to r respectively. The only catch is that the user is restricted to alternate his guesses between even and odd numbers. In other words, if his first value is an odd number, in the next step he has to choose an even number and so on. Ensure that your program restricts the user to do so. End the game in 20 steps and announce “You Lose!” if the user doesn’t win by then....
View Full Document
This note was uploaded on 04/14/2008 for the course COMP 202 taught by Professor Verbrugge during the Winter '07 term at McGill.
- Winter '07