diff --git a/src/test/java/org/example/StudentTest.java b/src/test/java/org/example/StudentTest.java index 30231f2..bba66d2 100644 --- a/src/test/java/org/example/StudentTest.java +++ b/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."); + } + } \ No newline at end of file