Browse Source

Test: Added testCalculateAverageGradeUsingTotalCredits()

remotes/origin/fdai7600
fdai7600 11 months ago
parent
commit
0c66a522ce
  1. 12
      src/test/java/org/example/StudentTest.java

12
src/test/java/org/example/StudentTest.java

@ -123,4 +123,16 @@ class StudentTest {
}
@Test
void testCalculateAverageGradeUsingTotalCredits() {
Student student = new Student("John Doe", "S1001", "Student");
Course math = new Course("Math", "M101", 5);
Course physics = new Course("Physics", "P101", 10);
student.getCourseGrades().put(math, "15");
student.getCourseGrades().put(physics, "12");
double expectedAverage = ((15.0 * 5) + (12.0 * 10)) / (5 + 10);
assertEquals(expectedAverage, student.calculateAverageGrade(), 0.01, "The calculated average grade is incorrect.");
}
}
Loading…
Cancel
Save