Problem description:
Your history instructor gives three tests worth up to 50 points each. Even though there are three tests, only two of them will be kept. Write a program that calculates and displays the letter grade received in the course using the grading scale shown below after the user enters the test scores. You need to determine which of tests 1 and 2 is being dropped, you need to keep track of which test was dropped, you need to calculate the total points for the two test scores used and you need to determine the letter grade earned. Note that you are not required to validate the test values. The output should list all three test scores, state which of the first two tests was dropped (test 1 or test 2), and give the total points for the two tests used, and letter grade earned.
Use the following table for assigning the letter grade.
Points Letter Grade
>= 92 A
< 92, >= 82 B
< 82, >= 72 C
< 72 F
For example, given below is a sample run of a program that satisfies the requirements of this exercise.
Enter the score for test #1: 45[Enter]
Enter the score for test #2: 15[Enter]
Enter the score for test #3: 37[Enter]
First test: 45
Second test: 15
Third test: 37
After dropping test #2, the points earned are 82.
The letter grade is B.
Test your program giving the same inputs in the sample run above.
package testApp;
package testApp;
import java.util.Scanner;
public class testApp {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int testone, testtwo, testthree;
int total;
System.out.print("Enter the score for test #1: ");
testone = input.nextInt();
System.out.print("Enter the score for test #2: ");
testtwo = input.nextInt();
System.out.print("Enter the score for test #3: ");
testthree = input.nextInt();
System.out.println("First test: " + testone);
System.out.println("Second test: " + testtwo);
System.out.println("Third test: " + testthree);
if (testone > testtwo) {
total = testone + testthree;
System.out.println("After dropping test #2, the points earned are "
+ total);
} else {
total = testtwo + testthree;
System.out.println("After dropping test #1, the points earned are "
+ total);
}
if (total >= 92) {
System.out.println("The letter grade is A");
} else if (total >= 82) {
System.out.println("The letter grade is B");
} else if (total >= 72) {
System.out.println("The letter grade is C");
} else {
System.out.println("The letter grade is F");
}
}
}