0% found this document useful (0 votes)
16 views4 pages

Java Student Enrollment & Grade Tool

The document outlines a workshop for creating a Java application to manage student course enrollments and grades using object-oriented programming. It includes requirements for designing class hierarchies for courses and students, as well as behaviors for entering courses and students, and displaying reports. The application should utilize collections for data management and generate reports based on student performance in their enrolled courses.

Uploaded by

Thanh Tùng Lê
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Java Student Enrollment & Grade Tool

The document outlines a workshop for creating a Java application to manage student course enrollments and grades using object-oriented programming. It includes requirements for designing class hierarchies for courses and students, as well as behaviors for entering courses and students, and displaying reports. The application should utilize collections for data management and generate reports based on student performance in their enrolled courses.

Uploaded by

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

Workshop 4: Student-Course Enrollment & Grade Analyzer

Description
In this workshop, you will create a Java application to manage students and their course
enrollments, using object-oriented programming principles:
- Use inheritance and polymorphism to model different student types.
- Allow users to input a dynamic list of courses.
- Track which course each student is enrolled in using a course code reference.
- Use collections to manage data.
- Generate a report that displays all students grouped by course, showing pass/fail status
and letter grades.

Requirements
1. Create a new Java project named Workshop4. The main class should be
workshop4.Workshop4

2. Design a class hierarchy as follows:

Class Course
Course
- code: String
- name: String
+ Course(code, name)
+ getCode(): String
+ getName(): String
+ setCode(String code): void
+ setName(String name): void
Base Class: Student
Student
-name: String
-age: int
-code: String
-grade: int
+Student(name, age, code, grade)
+getName(): String
+getAge(): int
+getCode(): String
+getGrade(): int
+getCourse(): Course
+setName(name: String): void
+setAge(age: int): void
+setCode(code: String): void
+setGrade(grade: int): void
+setCourse(course: Course): void
+isValidCode(): boolean
+isPassed(): boolean
+getLetterGrade(): String

Subclass: UndergraduateStudent inherits Student

UndergraduateStudent

+isPassed(): Boolean // grade >= 50


+getLetterGrade(): String

Subclass: GraduateStudent inherits Student


GraduateStudent

+isPassed(): boolean // grade >= 70


+getLetterGrade(): String

Behaviors

Step 1: Enter Courses


1. Ask the user how many courses to enter.
2. For each course:
- Prompt for course code (e.g., CS101)
- Prompt for course name
3. Store all courses in a HashMap<String, Course> for easy lookup by code.

Step 2: Enter Students


1. Ask the user how many students to enter.
2. For each student:
- Ask if they are Undergraduate (U) or Graduate (G)
- Input: Name, Age, Student Code, Grade
- Show list of available course codes and names
- Ask user to enter course code for the student to enroll in
- Create student object and set courseCode field
- Add student to List<Student>
Note: Skip students with invalid course codes.

Step 3: Display Report


1. For each course in the course list:
- Find students whose courseCode matches the course code.
- If found:
- Print course info
- For each student:
- Print: name, type, grade, letter grade, pass/fail

Sample Output
Enter number of courses: 2
Course 1 code: CS101
Course 1 name: Intro to Programming
Course 2 code: CS202
Course 2 name: Data Structures

Enter number of students: 2

Enter student 1 type (U=Undergraduate, G=Graduate): U


Name: Alice
Age: 20
Code: SE12345
Grade: 65
Available courses:
CS101 - Intro to Programming
CS202 - Data Structures
Enter course code to enroll: CS101

Enter student 2 type (U=Undergraduate, G=Graduate): G


Name: Bob
Age: 24
Code: SE54321
Grade: 68
Enter course code to enroll: CS202

=== Students in Course: CS101 - Intro to Programming ===


Alice (Undergraduate) - Grade: 65 (D) - PASSED

=== Students in Course: CS202 - Data Structures ===


Bob (Graduate) - Grade: 68 (C) - FAILED

Submission Instructions
- Zip your entire project folder (with src and any .java files)
- File name format: StudentID_Name_Workshop4.zip
- Submit it to your LMS before the deadline

Common questions

Powered by AI

Choosing a HashMap for course storage provides O(1) time complexity for lookups, essential for validating course codes efficiently. However, if order of insertion is significant, using a LinkedHashMap could be beneficial. Alternatively, a TreeMap would offer sorted order by course code, but at the cost of O(log n) operations. The choice should reflect trade-offs between lookup performance requirements and additional ordering or sorting needs .

Report generation involves several steps: iterating over each course stored in the application, identifying students with matching course codes, and retrieving their details. For each student, the report prints their name, type, grade, computed letter grade, and pass/fail status. This structured output provides a clear summary of student performance across courses .

The application prompts users to input a course code from a list of available courses when enrolling students. It uses a HashMap<String, Course> to store courses for easy lookup. If a course code entered by a user does not match any key in the HashMap, the student is skipped, ensuring only valid course enrollments are processed .

Introducing a DoctoralStudent subclass would involve implementing the getLetterGrade() and isPassed() methods with criteria specific to Doctoral requirements. Extending the existing design pattern, these methods could reflect higher grade thresholds or different passing scores. This modular approach, consistent with current implementations for undergraduate and graduate students, ensures the system's adaptability without impacting other components .

The Course class encapsulates course code and name, serving as an entity that student objects are linked to. By storing course information in a HashMap, courses become central reference points for student enrollment. Students, via their courseCode attribute, maintain a relationship with a specific Course instance, allowing for organized course-student data management and report generation .

The application uses overridden isPassed() methods in the UndergraduateStudent and GraduateStudent classes. Undergraduate students pass if their grade is 50 or above, while graduate students require a grade of 70 or above to pass. This distinction reflects the application of different academic standards for the student categories, allowing for accurate pass/fail determination based on educational level .

The application uses a HashMap to store courses by their unique code, enabling quick access and validation. Simultaneously, a List<Student> is used to manage student data, allowing for iterative operations like filtering students by course codes during report generation. These collections ensure efficient data manipulation necessary for enrollment management and report generation .

To enhance the application for extensibility, introduce an abstract class or interface, such as AbstractStudent or IStudent, defining common behaviors like isPassed() and getLetterGrade(). Each student type should implement this interface or extend the abstract class. This pattern decouples specific student logic from the base class, making it simpler to add new student types by merely implementing the required behavior, ensuring minimal disruption to the existing system .

Inheritance and polymorphism allow the application to model different student types (Undergraduate and Graduate) while sharing common features such as name, age, and code. The Student class serves as a base class with subclasses like UndergraduateStudent and GraduateStudent, which override methods such as isPassed() and getLetterGrade() to provide specific behavior based on student type. This design ensures code reusability and flexibility where new student types can be added with minimal changes .

Console-based input simplifies implementation and is platform-independent, making it accessible for users across various systems. However, it limits user interaction options, lacks input validation feedback, and is prone to input errors due to the absence of graphical guidance. This minimalistic interface might hinder usability, especially for users unfamiliar with command-line tools .

You might also like