Previous Next
0 / 6
Module DEMO-32-57DEMO-C-32

Grade Rounding

DEMO-C-32 • Programming in C

Browser-only practice

Problem Statement

Grade Rounding

You are tasked with implementing a grade rounding system according to specific rules. This is commonly used in educational settings to round up student grades under certain conditions.

Rules

  • If the grade is less than 38, do not round it.
  • If the grade is 38 or higher, check the next multiple of 5:
  • If the difference between the grade and the next multiple of 5 is less than 3, round the grade up to that multiple of 5.
  • Otherwise, keep the grade unchanged.

Examples

  • A grade of 84 rounds up to 85 (difference is 1).
  • A grade of 29 stays as 29 (less than 38).
  • A grade of 73 rounds up to 75 (difference is 2).
  • A grade of 67 stays as 67 (next multiple is 70, difference is 3, which is not less than 3).

Constraints

0 ≤ g ≤ 100

Input Format

A single integer g representing the raw grade.

  • Type: Integer
  • Range: 0 ≤ g ≤ 100

Output Format

Output a single integer representing the final grade after applying the rounding rules.

  • No extra formatting or spacing is required.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
84
85
Grade 84 rounds up to 85 because the next multiple of 5 is 85 and the difference is 1 (< 3).
Sample #2
Public sample
29
29
Grade 29 does not round up because it is below 38.
Sample #3
Public sample
73
75
Grade 73 round up because the difference to the next multiple of 5 (75) is 2
Sample #4
Public sample
38
40
Grade 38 rounds up to 40 because the next multiple of 5 is 40 and the difference is 2 (< 3).
Sample #5
Public sample
0
0
Grade 0 does not round up because it is below 38.
Sample #6
Public sample
100
100
Grade 100 stays as 100 because it's already a multiple of 5.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings