Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using if-else statement import java.util.*; public class GradeWithIfElse { publi

ID: 3805550 • Letter: U

Question

Using if-else statement

import java.util.*;

public class GradeWithIfElse {

public static void main(String[] args) {

       Scanner s = new Scanner(System.in);

       System.out.print("Enter the marks: ");

       int g = s.nextInt();

       char grade='F';

       if(g>=90)

           grade='A';

       else if(g>=80&&g<90)

           grade='B';

       else if(g>=70&&g<80)

           grade='C';

       else if(g>=60&&g<70)

           grade='D';

       else if(g<60)

           grade='F';

          

       System.out.println("Grade is: "+grade);

}

}

code this using dialog box in java JOptionPane

Explanation / Answer

Scanner s = new Scanner(System.in);

       System.out.print("Enter the marks: ");

       int g = s.nextInt();

       char grade='F';

       if(g>=90)

           grade='A';

       else if(g>=80&&g<90)

           grade='B';

       else if(g>=70&&g<80)

           grade='C';

       else if(g>=60&&g<70)

           grade='D';

       else if(g<60)

           grade='F';

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote