PROBLEM 16
Easy

Grade by Score

Programming Basics · Java

</>
STATUS Not solved

TASK

Problem

#16

Read an integer score from 0 to 100. Print `A` for 90–100, `B` for 75–89, `C` for 60–74, `D` for 40–59, and `F` otherwise.

EXAMPLE

Example

Input
95
Output
A

LIMITS

Constraints

0 ≤ score ≤ 100
📖
LEARN Theory for this problem
+

The core idea of **Grade by Score** is to model the requested operation directly: Read an integer score from 0 to 100. Print `A` for 90–100, `B` for 75–89, `C` for 60–74, `D` for 40–59, and `F` otherwise. The reference solution uses `Scanner` for input. Keep only the state needed for this result, choose numeric types that cover the stated bounds, and preserve the exact input/output contract. This makes the solution easier to verify on boundary cases and avoids unrelated work.

💡
NEED HELP? Hints
+

['Follow the statement for **Grade by Score** literally and identify the smallest state needed to produce its output.', 'The reference solution relies on `Scanner` for input; test the smallest allowed input and one boundary case from the constraints.']

ANSWER Solution
+
// CodeMaster — Grade by Score
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int score = sc.nextInt();
        if (score >= 90) System.out.println("A");
        else if (score >= 75) System.out.println("B");
        else if (score >= 60) System.out.println("C");
        else if (score >= 40) System.out.println("D");
        else System.out.println("F");
    }
}