Programming Assignment Unit 5
Programming Assignment Unit 5
to a course, give the student a grade to a specific course and get the overall grade of the student:
Student Class:
import java.util.ArrayList;
import java.util.List;
Course Class:
import java.util.ArrayList;
import java.util.List;
switch (choice) {
case 1:
addCourse();
break;
case 2:
enrollStudent();
break;
case 3:
assignGrade();
break;
case 4:
calculateOverallGrade();
break;
case 5:
System.out.println("Exiting the program. Goodbye!");
System.exit(0);
default:
System.out.println("Invalid choice. Please try again.");
}
}
}
// Method to add a new course
private static void addCourse() {
System.out.print("Enter course code: ");
String courseCode = scanner.next();
scanner.nextLine();
if (course != null) {
CourseManagement.enrollStudent(student, course);
System.out.println("Student enrolled successfully!");
} else {
System.out.println("Course not found.");
}
}
if (student != null) {
// Get course details
System.out.print("Enter course code: ");
String courseCode = scanner.next();
if (course != null) {
// Get grade
System.out.print("Enter grade for the student: ");
double grade = scanner.nextDouble();