import org.springframework.context.annotation.Configuration;
Coding Practice Calculate the final grade based on the following criteria:
If the student didn’t complete homework, the grade is automatically “F.” If the student completed homework and the average of midterm and final exam scores is >= 70, the grade is “Pass.” Otherwise, the grade is “Fail.”
import java.util.Scanner;
public class GradeCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print(" Enter your midterm score (0-100): \n");
int midtermScore = scanner.nextInt();
System.out.print(midtermScore);
System.out.print("\n Enter your final exam score (0-100): \n");
int finalExamScore = scanner.nextInt();
System.out.print(finalExamScore);
System.out.print("\n Did you complete the homework (yes/no): \n");
String homeworkComplete = scanner.next().toLowerCase();
System.out.print(homeworkComplete);
// write code here
if (homeworkComplete.equals("no")) {
System.out.println("\n Your final grade is: " + "fail");
}
else if(homeworkComplete.equals("yes") && (finalExamScore + midtermScore)/2 >= 70){
System.out.println("\n Your final grade is: " + "pass");
}
else {
System.out.println("\n Your final grade is: " + "fail");
}
scanner.close();
}
}
GradeCalculator.main(null)
Enter your midterm score (0-100):
60
Enter your final exam score (0-100):
70
Did you complete the homework (yes/no):
yes
Your final grade is: fail