01
Overview

Accumulate a count; report a percentage.

Sum or count first; divide and scale at the end. Two passes — or one pass plus one calculation.

Many AP-style problems ask for a percentage: pass rate, attendance percentage, success ratio. The pattern: count the matches, divide by the total, multiply by 100 — with the right cast to avoid integer truncation.

On the AP exam, percentage math appears in classification FRQs and in tracing problems involving cast-vs-no-cast.

02
Core Concept

Count, cast, divide, scale.

Each step has its purpose.

The template

public double percentPassing(int[] scores, int threshold) {
    if (scores.length == 0) return 0.0;
    int passed = 0;
    for (int s : scores) {
        if (s >= threshold) passed++;
    }
    return 100.0 * passed / scores.length;
}

Why the literal 100.0?

Multiplying first by 100.0 forces the entire expression into double arithmetic. Without the decimal, 100 * passed / scores.length stays in integer land until the division — and truncates.

Cast alternative

return (double) passed / scores.length * 100;

Same result — the cast promotes the division to double.

Empty input

Guard against division by zero by returning a sensible value (often 0.0) when the array is empty.

03
Key Vocabulary

Percentage vocabulary.

Used in rate / ratio problems.

Vocabulary
  • Accumulator — counter or sum that grows during traversal.
  • Percentage — value out of 100.
  • Cast — explicit type conversion.
  • Integer truncation — losing the decimal when dividing ints.
  • Scale — multiplying by 100 to shift the decimal.
  • Empty-input guard — protecting against division by zero.
04
AP Exam Focus

How percentage math is tested.

Cast placement and empty-input handling dominate.

Exam Focus
  • Cast before integer division. Otherwise result truncates.
  • 100.0 literal trick. Forces double from the start.
  • Empty input guard. Don't divide by zero.
  • Return type double. Percentage typically has decimals.
05
Worked Example

Compute pass percentage.

Two scenarios — with and without cast.

Worked Example AP-style reasoning

Input: 7 passing students out of 10.

Wrong: 100 * 7 / 10 → 700 / 10 = 70 (correct here but only by luck).

Wrong: 7 / 10 * 100 → 0 * 100 = 0 (integer truncation kills the value).

Right: 100.0 * 7 / 10 → 700.0 / 10 = 70.0.

Right: (double) 7 / 10 * 100 → 0.7 * 100 = 70.0.

Lesson: Cast or use 100.0 to force double arithmetic.

06
Common Mistakes

Percentage pitfalls.

All are about types and order.

Watch Out
  • Integer-only arithmetic. 7 / 10 is 0.
  • Wrong cast position. Cast must be before the division to take effect.
  • Forgetting the empty-input guard. Division by zero on empty array.
  • Returning percentage as int. Loses the decimal.
07
Reference Table

Percentage math at a glance.

Three forms; pick one.

Percentage Reference

AP Quick Reference
ExpressionBehaviorRecommended?
100 * passed / totalRisky overflowNo.
100.0 * passed / totalCorrectYes.
(double) passed / total * 100CorrectYes.
passed / total * 100TruncatedNo.
08
Practice Tip

How to master percentages.

Always cast; always guard empty.

Practice Strategy
  • MCQ Practice — verify cast position and rule out integer-only options.
  • Java Lab — implement passRate, attendancePercent. Test empty arrays.
  • FRQ Practice — use 100.0 * at the start of percentage expressions.
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 09 Topic 07 Accumulation and Percentage Math FRQ Practice

AP-style topic practice assessment

Start