Scenario

Design a program that picks a secret whole number in a range (say, 1 to 100) and lets a player guess it, telling them after each guess whether they were too high, too low, or correct.

You decide the exact interaction and structure — this brief describes the outcome, not the implementation.

Requirements

Core

  • The program picks a secret number the player can’t see.
  • The player can guess repeatedly until they find it.
  • After each guess, the program says “too high,” “too low,” or “correct.”
  • The game ends once the player guesses correctly.

Stretch

  • Count and report how many guesses it took.
  • Let the player choose the range instead of hard-coding 1–100.
  • Limit the player to a maximum number of guesses.

Reflect

  • Which parts of your program track state that changes over time?
  • If you were to add a second player, what would need to change?

Suggested milestones

  1. Get a program that always “guesses” the same fixed number, and checks a hard-coded guess against it — no randomness or repetition yet.
  2. Add repetition so the player can guess more than once.
  3. Add a real secret number and the too-high/too-low/correct logic.
  4. Add one stretch requirement.

Acceptance checks

  • Guessing below the secret number reports “too low.”
  • Guessing above the secret number reports “too high.”
  • Guessing the exact number ends the game with a success message.
  • The game never crashes on a valid guess within the stated range.