Practice

Student Mark Categorizer

2022/Oct/Nov·Variant 2
MEDIUMSelection

A teacher needs a program to categorize student test marks. The program will continuously read integer marks until a value of -1 is entered.

The marks should be sorted into three categories:

  • Higher: 80 or greater
  • Middle: 50 to 79 (inclusive)
  • Lower: less than 50

At the end, output the total counts for each category.

Input: A sequence of integers ending with -1. Output: Three lines formatted as "Higher: X", "Middle: Y", and "Lower: Z".

Example:

Input:  85 50 49 90 12 -1
Output: Higher: 2
        Middle: 1
        Lower: 2
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Standard mix of grades
Inputs: 85, 50, 49, 90, 12, -1
Expected: Higher: 2 Middle: 1 Lower: 2
Test 2: Immediate termination
Inputs: -1
Expected: Higher: 0 Middle: 0 Lower: 0
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade