Practice

Weekly Screen Time Grid

2024/Feb/Mar·Variant 2·Q11·[12 marks]
HARD2D Arrays

Students log daily screen time (minutes) in a 2D array. StudentName[1:3] holds the names. ScreenTime[1:3, 1:3] holds three days of minutes for those same students (row = student, column = day).

Read the three names, then the 9 daily totals. For each student output their name, weekly total minutes, and how many days were more than 300 minutes. Then output the name of the student with the lowest weekly total (the earlier student wins a tie).

Inspired by Cambridge IGCSE Computer Science (0478) Feb/Mar 2024 Paper 22 Question 11 — shortened to 3 students × 3 days so it can be auto-graded.

Input: 3 names, then 9 integers (row by row). Output: Three <name> <total> <daysOver300> lines, then Lowest: <name>.

Example:

Input:  Amal
        Ben
        Chen
        320
        100
        80
        50
        60
        70
        310
        305
        10
Output: Amal 500 1
        Ben 180 0
        Chen 625 2
        Lowest: Ben
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Mixed days over 300
Inputs: Amal, Ben, Chen, 320, 100, 80, 50, 60, 70, 310, 305, 10
Expected: Amal 500 1 Ben 180 0 Chen 625 2 Lowest: Ben
Test 2: No day over 300; first student lowest
Inputs: Ivy, Omar, Pat, 10, 10, 10, 20, 20, 20, 30, 30, 30
Expected: Ivy 30 0 Omar 60 0 Pat 90 0 Lowest: Ivy