๐ WAYPOINT LESSON
Checkpoint: Statistics Bureau
โญ beginnerโณ 45 min read๐ Lesson 20 of 180
Average, pass rate, and second-largest in single passes โ accumulators, counters, and extremum tracking under one roof.
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):
int average(int[] scores)โ the mean rounded down to a whole number ((int)truncation is acceptable and expected).int passRate(int[] scores)โ the percentage of scores โฅ 60, rounded down (an integer 0โ100, not a double).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.