Grade Calculator

Easy~10 min

Given a numeric score (integer), return the corresponding letter grade as a string.

The grading scale is:

  • 90–100"A"
  • 80–89"B"
  • 70–79"C"
  • 60–69"D"
  • 0–59"F"

If the score is outside the range 0–100, return "Invalid".

Examples

Example 1
Input: score = 95
Output: "A"
Explanation: 95 falls in the 90–100 range.
Example 2
Input: score = 72
Output: "C"
Explanation: 72 falls in the 70–79 range.
Example 3
Input: score = -1
Output: "Invalid"
Explanation: -1 is outside the valid 0–100 range.

Constraints

  • -1000 <= score <= 1000
  • score is an integer.
Code
Ctrl+EnterRun|Ctrl+⇧+EnterSubmit
Output

Run your code to see results

Use Cmd+Enter to run