Read the question, write Java on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read score 0–100. Print A (≥90), B (≥80), C (≥70), D (≥60), else F.
Examples
Input
95
Output
A
Input
72
Output
C
Input
50
Output
F
Hint
- Chain if / else if from the top band down.
Show correct code
Peek only after you have tried. You can still Check your own version.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int s = in.nextInt();
if (s >= 90) System.out.println("A");
else if (s >= 80) System.out.println("B");
else if (s >= 70) System.out.println("C");
else if (s >= 60) System.out.println("D");
else System.out.println("F");
}
}
Main.javaJava 21 · javac · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.