Practice

Exclusive Range Running Total

2025/May/June·Variant 2·Q7·[6 marks]
EASYLoops

Read real numbers until five values have been accepted. A value is accepted only when it is strictly between -20 and 50 (so -20 and 50 are rejected). Output the total of the five accepted values, then their average.

Input: Numbers until five are in range. Output: Total, then average.

Example:

Input:  -20
        50
        0
        10
        20
        30
        40
Output: 100
        20

Sample Test Cases

Test 1: Both bounds rejected
Inputs: -20, 50, 0, 10, 20, 30, 40
Expected: 100 20
Test 2: Five valid values immediately
Inputs: 1, 2, 3, 4, 5
Expected: 15 3