Calculate average, high score, low score, and median from an array of test scores | Workbook p.77
What You're Building
Create an array of 10 test scores (hardcoded — no user input needed). Your program should calculate and display four statistics: the average of all scores, the highest score, and the lowest score. As a bonus challenge, also calculate the median — the middle value when scores are sorted in order. Remember that for an even number of scores, the median is the average of the two middle values.
Example Run
Run 1 — Basic Statistics
Test Scores: [85, 92, 76, 88, 95, 71, 89, 64, 93, 78]
Average score: 83.1
Highest score: 95
Lowest score: 64
Run 2 — With Bonus Median
Test Scores: [85, 92, 76, 88, 95, 71, 89, 64, 93, 78]
Average score: 83.1
Highest score: 95
Lowest score: 64
Median score: 86.5
Bonus detail: The median requires the scores to be in sorted order. For 10 scores, the median is the average of the 5th and 6th values in the sorted list. Be careful not to change your original array when sorting — work on a copy.
Flow Diagram
Create scores array
10 hardcoded values
→
Calculate sum & average
Loop through all scores
→
Find highest score
Track the max
Find lowest score
Track the min
→
Sort a copy
Bonus: don't change original
→
Find median
Bonus: avg of 2 middle values
Display all statistics
Average, high, low, (median)