Define the Valid Range for an Input
Scenario
A classroom quiz scores whole points from 0 through 100 inclusive.
Try it yourself
Check which values lie inside the valid range and which fall outside.
| Case | Result |
|---|---|
| score = 0 | Select a choice above to see what happens. |
| score = 100 | Select a choice above to see what happens. |
| score = -1 or score = 101 | Select a choice above to see what happens. |
Reveal the explanation
- score = 0
Valid lower bound. Normal pass/fail rule applies (Fail).
- score = 100
Valid upper bound. Normal pass/fail rule applies (Pass).
- score = -1 or score = 101
Out of valid range. Must trigger the declared invalid-input behavior.
Naming both endpoints (0 and 100) and whether they are inclusive lets every test agree on where valid data ends and invalid input begins.
Download shared test cases
Your turn
Declare the valid range for a study room with 8 total seats (requestedSeats and freeSeats).
Common mistake Forgetting the upper bound so freeSeats = 50 is accepted for an 8-seat room.
Check your work
Exact inclusive ranges: freeSeats in 0..8 and requestedSeats in 1..8 (whole integers).
Quick check
This browser could not save your progress. Changes last until you leave the page.