0% found this document useful (0 votes)
34 views1 page

Online Java Compiler

This document shows a Java program that takes a student's grade as input using a Scanner, then uses if/else statements to output the corresponding letter grade based on the following thresholds: A for grades 98 and above, A- for grades 90-97, B for grades 86-89, and B- for grades 80-85. The program imports the Scanner utility, defines a main method that declares an integer variable for the grade, initializes the Scanner to read integer input, prints a prompt, assigns the input to the grade variable, and contains the nested if/else statements to evaluate and print the letter grade.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

Online Java Compiler

This document shows a Java program that takes a student's grade as input using a Scanner, then uses if/else statements to output the corresponding letter grade based on the following thresholds: A for grades 98 and above, A- for grades 90-97, B for grades 86-89, and B- for grades 80-85. The program imports the Scanner utility, defines a main method that declares an integer variable for the grade, initializes the Scanner to read integer input, prints a prompt, assigns the input to the grade variable, and contains the nested if/else statements to evaluate and print the letter grade.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Java Course

Online Java Compiler

Main.java Output

1 import java.util.Scanner;  
2 public class Grades{
3 public static void main (String []
        args){
4 int grade;
5 Scanner grade=new Scanner (System
            .in);
6
7 System.out.println("input your
            grades: ");
8 grade=grade.nextInt();
9
10 if (grade>=98) {
11 System.out.println("you got A"
                );
12 }
13 else if (grade>=90) {
14 System.out.println("you got A-
                ");
15 }
16 else if (grade>=86) {
17 System.out.println("yout got
                B");
18 }
19 else if (grade>=80) {
20 System.out.println("you got B-
                "); Run
21 }

You might also like