Write a simple Java program that will take as input a numer

) Write a simple Java program that will take as input a numeric grade between 0-100 and will print out a letter grade for the user based upon the following scale: You do not need to write an entire/complete program just the code necessary to declare any variables you need, the input and the processing of the value to print the output.

0-59     F

60-69   D

70-79   C

80-89   B

90-100 A

Solution

Grade.java


import java.util.Scanner;

public class Grade {//main class
    public static void main (String args[])
    {//main method
        Scanner sc=new Scanner(System.in);
        try{
        System.out.println(\"Enter the numeric grade between 0 to 100 :\");
        int Numericgrade=sc.nextInt();//key board inputting
        if(Numericgrade>=0 && Numericgrade<=59)
            System.out.println(\" Grade is F\");
       else if(Numericgrade>=60 && Numericgrade<=69)
            System.out.println(\" Grade is D\");
       else if(Numericgrade>=70 && Numericgrade<=79)
            System.out.println(\" Grade is C\");
       else if(Numericgrade>=80 && Numericgrade<=89)
            System.out.println(\" Grade is B\");
       else if(Numericgrade>=90 && Numericgrade<=100)
            System.out.println(\" Grade is A\");
        else
            System.out.println(\"Invalid input\");
    }
  
    catch(Exception e)
    {
        System.out.println(\"please enter interger between 0 to 100\");
    }
  
}
}

output

Enter the numeric grade between 0 to 100 :
98
Grade is A

) Write a simple Java program that will take as input a numeric grade between 0-100 and will print out a letter grade for the user based upon the following scal

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site