Assigning values to range buckets.
Letter grades, tax brackets, age groups — every problem that maps a number to a category uses range buckets.
Range buckets classify numeric values into discrete categories: 90+ → A, 80-89 → B, and so on. The cleanest implementation uses an if/else if ladder ordered from highest to lowest.
Tie-breaking resolves what happens at the exact boundary — does 80 go to B or C? The choice of > vs >= answers it.
On the AP exam, range buckets appear in classification FRQs and in MCQs that test boundary value tracing.
Order from most specific to most general.
First matching branch wins.
Letter grade buckets
public String letterGrade(int score) {
if (score >= 90) return "A";
else if (score >= 80) return "B";
else if (score >= 70) return "C";
else if (score >= 60) return "D";
else return "F";
}
Ordered high to low. The first true condition fires; no later branches run.
Why order matters
If you check score >= 60 first, a 95 would return "D" — the first match wins before A is even considered.
Tie-breaking: 80 → B or C?
score >= 80 places 80 in B. score > 80 would place 80 in C. The choice usually depends on the spec.
Default branch
The final else catches everything below 60. Always provide one so the method always returns.
Range-bucket vocabulary.
Used in classification problems.
- Range bucket — a category defined by a numeric range.
- Tier — another name for bucket.
- Boundary value — the exact value separating two ranges.
- Tie-breaking — choosing which bucket gets the boundary value.
- Default branch — final
elsecatching unhandled cases. - Specific-to-general — order requirement for if/else if ladders.
How range buckets are tested.
Order and boundary handling dominate.
- Order high to low. Most restrictive condition first.
- Boundary inclusion.
>=vs>per spec. - Default branch. Required for completeness.
- Else-if, not independent ifs. Prevents multiple matches.
Trace boundary values.
Verify each tier's inclusive endpoint.
Using letterGrade above:
- 95 → A (95 >= 90).
- 90 → A (boundary; >= 90).
- 89 → B (89 >= 80).
- 80 → B.
- 79 → C.
- 59 → F.
What if we used > 90 instead? 90 would become B — boundary moves down.
Range-bucket pitfalls.
Most are order or boundary errors.
- Order low to high. Wrong tier matches first.
- Independent
ifs. Multiple branches fire; results unpredictable. - Missing default. Method may not return on every path.
- Wrong boundary operator. 80 → C instead of B.
Range-bucket checklist.
Order, operator, default.
Range Buckets Reference
AP Quick Reference| Element | Rule | Reason |
|---|---|---|
| Order | High to low | First match wins. |
| Branches | else if | Prevents multiple matches. |
| Boundary | >= or > | Per spec. |
| Default | Final else | Always returns. |
How to master range buckets.
Sketch the number line; verify boundaries.
- MCQ Practice — test boundary values explicitly to detect off-by-one.
- Java Lab — write letterGrade, ageGroup, taxBracket. Trace each boundary.
- FRQ Practice — read the prompt for "at least" vs "more than" before choosing the operator.
Practice — attempt these now.
AP-style assessments aligned to this lesson. Time them.
AP CSA Unit 09 Topic 06 Range Buckets and Tie-Breaking FRQ Practice
AP-style topic practice assessment