Practice
Student Age Category Counter
2022/Feb/Mar·Variant 2
MEDIUMSelection
Write an algorithm to categorise the ages of a number of students. First, input N (the number of students). Then, input N integer ages. Count and output the number of students in four categories: under 7, 7 to 11, 12 to 17, and 18 and over.
Input: Integer N, followed by N integer ages.
Output: Four lines in the exact format shown.
Example:
Input: 5
6
7
12
18
20
Output: Under 7: 1
7 to 11: 1
12 to 17: 1
18 and over: 2
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: One in each lower, two in highest
Inputs: 5, 6, 7, 12, 18, 20
Expected: Under 7: 1
7 to 11: 1
12 to 17: 1
18 and over: 2
Test 2: All under 7
Inputs: 3, 5, 5, 5
Expected: Under 7: 3
7 to 11: 0
12 to 17: 0
18 and over: 0
Ctrl+Enter
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to check