Skip to main content

Checkpoint: Statistics Bureau

Challenge on lesson: Checkpoint: Statistics Bureau

The Statistics Bureau processes test scores in one pass each. Implement three methods over an int[] scores (each 0–100; the array is never empty): 1. int average(int[] scores) — the mean **rounded down** to a whole number ((int) truncation is acceptable and expected). 2. int passRate(int[] scores) — the percentage of scores ≥ 60, rounded down (an integer 0–100, not a double). 3. int secondLargest(int[] scores) — the second-largest DISTINCT value; every score is guaranteed to appear at least twice or the array is guaranteed to hold at least two distinct values — when all values are identical, return that value itself. One loop per method (no Arrays.sort — this is a loops exercise), each carrying only the state it needs. average({70, 80, 91}) is 80; passRate({70, 80, 91}) is 100; secondLargest({90, 90, 85}) is 85.

Difficulty: beginner

Back to lesson: Checkpoint: Statistics Bureau