السؤال الثاني عشر من Lab4:
Your history instructor gives three tests worth 50 points each. You can drop one of the first two grades. Your final grade is the sum of the best of the first two grades and the third grade. Given three test grades, write a program that calculates the final letter grade using the following cut-off points. The output should list all three test grades, state what test was dropped and the final letter grade
>= 90 A
< 90, >= 80 B
< 80, >= 70 C
< 70, >= 60 D
< 60 F
For example, if your input is 45 15 25 (you do not need to format the input), the output of your program should be very similar to:
First test: 45
Second test: 15
Third test: 25
After dropping test 2, the final grade is 70. The final letter grade is C.
السورس كود:
كود PHP:
import java.util.*;
/
*
* @author deathpa1N
*/
public class Exercise12 {
/
* @param args the command line arguments
*/
public static void main(String[] args) {
double Test1, Test2, Test3,Sum=0;
char grade='A';
Scanner input = new Scanner (System.in);
System.out.print("Enter your grade at the first test: ");
Test1 = input.nextDouble();
System.out.print("Enter your grade at the second test: ");
Test2 = input.nextDouble();
System.out.print("Enter your grade at the third test: ");
Test3 = input.nextDouble();
System.out.println("First Test: " + Test1);
System.out.println("Second Test: " + Test2);
System.out.println("Third Test: " + Test3);
if( Test1 > Test2){
System.out.print("After dropping test 2, The final grade is ");
Sum=Test1+Test3; }
else if( Test2 > Test1){
System.out.print("After dropping test 1, The final grade is ");
Sum=Test2+Test3;}
if (Sum >= 90){
grade='A';}
else if ((Sum < 90)&&(Sum >=80)){
grade='B';}
else if ((Sum < 80)&&(Sum >=70)){
grade='C';}
else if ((Sum < 70)&&(Sum >=60)){
grade='D';}
else if (Sum<60){
grade='F';}
System.out.println(Sum+". The final letter grade is "+grade);
System.exit(0);
}
}
السؤال بسيط ولا اعتقد إنه يحتاج شرح، إذا كان في شيء واضح أسألوا