Write a program that calculates the letter grade based on the average of 3 exam
ID: 3565218 • Letter: W
Question
Write a program that calculates the letter grade based on the average of 3 exam grades. The average of 3 exams is calculated based on the exam weight, which is as follows
Exam 1 20%
Exam 2 30%
Exam 3 50%
Once the average is calculated, the final letter grade can be determined. The letter grade is determined based on the following,
A >= 90
B < 90 and >= 80
C < 80 and >= 70
D < 70 and >= 60
F < 60
Display the average grade and letter grade in your output.
Help please!!!!!
Explanation / Answer
import java.util.Scanner;
public class GradeAverageLoop
{
public static void main(String[] args){
Scanner input = new Scanner (System.in);
double exam1, exam2, exam3, exam4, i, grade;
i = 1;
while(i < 4)
{
System.out.println( "Please Enter Your First Exam Grade: ");
exam1 = input.nextDouble();
System.out.println("");
System.out.println( "Please Enter Your Second Exam Grade: ");
exam2 = input.nextDouble();
System.out.println("");
System.out.println( "Please Enter Your Third Exam Grade: ");
exam3 = input.nextDouble();
System.out.println("");
System.out.println( "Please Enter Your Forth Exam Grade: ");
exam4 = input.nextDouble();
System.out.println("");
grade = Math.round(exam1 + exam2 + exam3 + exam4)/ 4.0;
System.out.println("");
System.out.println("The Average is: " + grade);
if(grade >= 90)
System.out.println("You are fantastic! You got a A!");
else if (grade >= 80)
System.out.println("You did a great job! You got a B!");
else if (grade >= 70)
System.out.println("You could do better! You got a C!");
else if (grade >= 60)
System.out.println("You need to study hardier! You got a D!");
else
System.out.println("You will need to take this course again! You got a F!");
i = i + 1;
break;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.