0% found this document useful (0 votes)
37 views6 pages

Course Enrollment & Grade Management System

The document describes a student course enrollment and grade management system with classes for students, courses, and course management. It allows adding courses, enrolling students in courses, assigning grades, and calculating overall grades.

Uploaded by

albertmutoya57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views6 pages

Course Enrollment & Grade Management System

The document describes a student course enrollment and grade management system with classes for students, courses, and course management. It allows adding courses, enrolling students in courses, assigning grades, and calculating overall grades.

Uploaded by

albertmutoya57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ASSIGNMENT-5 COURSE ENROLLMENT AND GRADE MANAGEMENT SYSTEM

import [Link];
import [Link];
import [Link];

class Student {
private String name;
private int studentID;
private List<Course> enrolledCourses;

public Student(String name, int studentID) {


[Link] = name;
[Link] = studentID;
[Link] = new ArrayList<>();
}

public String getName() {


return name;
}

public int getStudentID() {


return studentID;
}

public List<Course> getEnrolledCourses() {


return enrolledCourses;
}

public void enrollInCourse(Course course) {


[Link](course);
}

public void assignGrade(Course course, int grade) {


// Implement logic to assign grades
}
}

class Course {
private String courseCode;
private String courseName;
private int maxCapacity;
private static int totalEnrolledStudents = 0;

public Course(String courseCode, String courseName, int maxCapacity) {


[Link] = courseCode;
[Link] = courseName;
[Link] = maxCapacity;
}

public String getCourseCode() {


return courseCode;
}

public String getCourseName() {


return courseName;
}

public int getMaxCapacity() {


return maxCapacity;
}

public static int getTotalEnrolledStudents() {


return totalEnrolledStudents;
}

public static void incrementEnrolledStudents() {


totalEnrolledStudents++;
}
}

class CourseManagement {
private static List<Course> courses = new ArrayList<>();
private static List<Student> students = new ArrayList<>();

public static void addCourse(String courseCode, String courseName, int maxCapacity) {


Course newCourse = new Course(courseCode, courseName, maxCapacity);
[Link](newCourse);
}

public static void enrollStudent(Student student, Course course) {


if ([Link]() > [Link]()) {
[Link](course);
[Link]();
} else {
[Link]("Course has reached maximum capacity. Enrollment failed.");
}
}

public static void assignGrade(Student student, Course course, int grade) {


[Link](course, grade);
}
public static void calculateOverallGrade(Student student) {
// Implement logic to calculate overall course grade for the student
}

public static List<Course> getCourses() {


return courses;
}

public static List<Student> getStudents() {


return students;
}

public static Student findStudentByID(int studentID) {


for (Student student : students) {
if ([Link]() == studentID) {
return student;
}
}
return null;
}

public static Course findCourseByCode(String courseCode) {


for (Course course : courses) {
if ([Link]().equals(courseCode)) {
return course;
}
}
return null;
}
}

class AdministratorInterface {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
Student student = null; // Declare student variable

while (true) {
[Link]("1. Add a new course");
[Link]("2. Enroll students");
[Link]("3. Assign grades");
[Link]("4. Calculate overall course grades");
[Link]("0. Exit");

[Link]("Enter your choice: ");


try {
int choice = [Link]([Link]());

switch (choice) {
case 1:
// Logic to add a new course
[Link]("Enter course code: ");
String courseCode = [Link]();
[Link]("Enter course name: ");
String courseName = [Link]();
[Link]("Enter maximum capacity: ");
int maxCapacity = [Link]();
[Link](courseCode, courseName, maxCapacity);
[Link]("Course added successfully!");
break;

case 2:
// Logic to enroll students
[Link]("Enter student name: ");
String studentName = [Link]();
[Link]("Enter student ID: ");
int studentID = [Link]();
[Link](); // Consume the newline character

// Initialize student here


student = new Student(studentName, studentID);

// Display available courses for enrollment


[Link]("Available courses for enrollment:");
for (Course c : [Link]()) {
[Link]([Link]() + ": " + [Link]());
}

// Prompt for course code to enroll in


[Link]("Enter course code to enroll in: ");
String enrollCourseCode = [Link]().trim();

// Find the course with the entered code and enroll the student
Course enrollCourse = [Link](enrollCourseCode);
if (enrollCourse != null) {
[Link](student, enrollCourse);
[Link]("Enrollment successful!");
} else {
[Link]("Invalid course code. Enrollment failed.");
}
break;
case 3:
// Logic to assign grades
// ... (unchanged)
break;

case 4:
// Logic to calculate overall course grades
// ... (unchanged)
break;

case 0:
[Link]("Exiting the program. Goodbye!");
[Link](0);
default:
[Link]("Invalid choice. Please try again.");
}
} catch (NumberFormatException e) {
[Link]("Invalid input. Please enter a valid numeric choice.");
}
}
}
}

Common questions

Powered by AI

The method `assignGrade` is defined but lacks implementation details for assigning grades to students. The system requires logic to actually record and perhaps validate assigned grades against students and their respective enrolled courses .

The effectiveness of the course searching mechanism relies on matching the input course code with existing course codes in the system. If a valid code is entered, the system can facilitate enrollment. However, the mechanism's effectiveness is limited if courses are misnamed or unavailable in the list, as this would lead to enrollment failure. Improvements could include suggestions for similar course codes based on input .

The system checks if the maximum capacity of the course is greater than the total number of enrolled students before allowing enrollment. If space is available, the student is enrolled in the course, and the count of enrolled students is incremented. Otherwise, the system informs that the course has reached maximum capacity and enrollment fails .

The system uses a `switch` statement with cases corresponding to user menu choices. Each case triggers different system operations such as adding new courses, enrolling students, and assigning grades. Invalid inputs are handled by default cases which prompt the user to re-enter their choice, ensuring controlled decision-making paths .

The possible outcomes include successful enrollment if the course capacity allows or failure if the course code is invalid or the course has reached its maximum capacity. The system outputs relevant messages to inform the user whether the enrollment was successful or why it failed .

Not using synchronized blocks when updating the static variable `totalEnrolledStudents` could lead to race conditions if multiple threads try to enroll students simultaneously. This may cause inconsistent data states, such as incorrect enrollment numbers, potentially leading to over-enrollment beyond the course capacity .

To manage course prerequisites, each Course object needs an associated list of prerequisite course codes. During enrollment, the system should check if the student has completed required courses by reviewing their grade records. Implement a method in the Course class to verify prerequisites are met before allowing enrollment .

An approach is to enhance the `calculateOverallGrade` method to iterate through a student's enrolled courses, retrieve assigned grades, and calculate weighted averages based on course credits or importance. This requires expanding the course and grade structures to store such data, ensuring meaningful overall grade computation .

One potential issue is the use of a static counter for enrolled students, which doesn't reflect course-specific enrollment. This can lead to inaccuracies if multiple instances of courses exist. An improvement would be to maintain a separate enrollment count for each course instance, ensuring accurate monitoring of each course's capacity .

Improper management of dynamic student objects in the main interface could lead to memory leaks or lost data if objects are not reused efficiently. This mismanagement might also result in incorrect data processing during operations like enrollment and grade assignments, affecting the overall reliability of the system .

You might also like