01
Overview

Clamp values, then measure the pass rate.

Two passes: first to bound values into a legal range, then to count how many meet a threshold.

Clamping restricts values to a range: anything below the floor becomes the floor; anything above the ceiling becomes the ceiling. Pass rate is the proportion of elements that exceed (or meet) a threshold.

The combined pattern: clamp the data first to remove outliers, then compute the pass rate over the clean data. Common in grade adjustment, score validation, and quality measurement.

On the AP exam, this appears in FRQs about test scores with caps, sensor data with limits, or scaled measurements.

02
Core Concept

Pass 1: clamp in place. Pass 2: count and divide.

Each pass has a single, clear job.

Clamping in place

public void clampAll(int[] arr, int min, int max) {
    for (int i = 0; i < arr.length; i++) {
        if (arr[i] < min) arr[i] = min;
        else if (arr[i] > max) arr[i] = max;
    }
}

Indexed loop is required for mutation. Enhanced-for cannot modify the array.

Pass rate

public double passRate(int[] arr, int threshold) {
    if (arr.length == 0) return 0.0;
    int passed = 0;
    for (int n : arr) {
        if (n >= threshold) passed++;
    }
    return (double) passed / arr.length;
}

Returns a value in [0.0, 1.0]. Multiply by 100 for a percentage.

Combined workflow

clampAll(grades, 0, 100);
double rate = passRate(grades, 60);
03
Key Vocabulary

Clamp and rate vocabulary.

Used in score-processing problems.

Vocabulary
  • Clamp — restrict a value to a range.
  • Floor / ceiling — minimum and maximum allowed values.
  • In-place — modifying the array without allocating a new one.
  • Pass rate — fraction or percentage meeting a threshold.
  • Threshold — boundary that defines passing.
  • Outlier — value outside the legal range.
04
AP Exam Focus

How clamp and pass rate are tested.

In-place mutation and accurate division dominate.

Exam Focus
  • Indexed loop for mutation. Enhanced-for cannot mutate.
  • Cast for accurate rate. (double) passed / arr.length.
  • Threshold inclusion. "At least" includes; "above" excludes.
  • Empty-array safety. Don't divide by zero.
05
Worked Example

Clamp grades, then compute pass rate.

Trace both passes.

Worked Example AP-style reasoning

Input: [105, 45, 60, -3, 88, 72]; clamp [0, 100]; threshold 60.

After clamping: [100, 45, 60, 0, 88, 72].

Pass count: 100, 60, 88, 72 → 4.

Pass rate: 4 / 6 = 0.666... (about 67%).

06
Common Mistakes

Clamp/rate pitfalls.

Most are mutation or division errors.

Watch Out
  • Enhanced-for to mutate. Doesn't change the array.
  • Integer division. passed / arr.length truncates.
  • Wrong threshold direction. "Above" vs "at least".
  • Forgetting empty-array guard. Division by zero crash.
07
Reference Table

Clamp + rate at a glance.

Two passes; one cast.

Clamp & Rate Reference

AP Quick Reference
OperationLoop typeDetail
ClampIndexedMutate in place.
CountEnhanced forRead-only.
RateOne divideCast to double.
Empty arrayReturn 0.0Guard divide.
08
Practice Tip

How to master clamp and rate.

Two short methods; combine in the caller.

Practice Strategy
  • MCQ Practice — verify the loop type matches the operation; verify cast in rate.
  • Java Lab — implement clampAll and passRate as separate methods. Chain in the test harness.
  • FRQ Practice — when an FRQ has "limit then measure" phrasing, split into two methods.
09
Section · 09

Practice — attempt these now.

AP-style assessments aligned to this lesson. Time them.

FRQ Practice 30 min 18 marks Pending

AP CSA Unit 07 Topic 09 In-Place Clamping and Pass Rate FRQ Practice

AP-style topic practice assessment

Start