Skip to main content

Checkpoint: Statistics Bureau

Challenge on lesson: Checkpoint: Statistics Bureau

CHALLENGE
Difficulty: beginner+25 XP

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.

Back to lesson: Checkpoint: Statistics Bureau