Write a Java program to display a letter grade based on an actual grade.
A = 90-100
B = 80-89
C = 70-79
D = 60-69
F = less than 60 The program needs to do the following: 1. Create a short integer to store a grade. (See Week 3 - Things to Know - Java Data Types ) 2. Prompt for a grade ( 0-100). 3. Based on the grade given, use IF statements to display the letter grade associated with the numeric grade. This can all be done inside the main() method.
Example input/output: Enter Grade (0-100): 88 Letter Grade is B
//LetterGrade.java import java.util.Scanner; public class LetterGrade { public static void main(String args[]){ Scanner scanner = new Scanner(System.in); System.out.print("Enter Grade (0-100): "); double grade = scanner.nextDouble(); System.out.print("Letter grade is "); if(grade<60){ System.out.println("F"); } else if(grade<70){ System.out.println("D"); } else if(grade<80){ System.out.println("C"); } else if(grade<90){ System.out.println("B"); } else { System.out.println("A"); } } }
Get Answers For Free
Most questions answered within 1 hours.