Skip to content

Commit 9f5e7f7

Browse files
Add files via upload
1 parent 3fc4fe6 commit 9f5e7f7

23 files changed

+1633
-0
lines changed

Student Management System/App.java

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
import java.util.*;
2+
import packages.system.*;
3+
import packages.fileHandler.*;
4+
5+
// ---------------------------------------------- MAIN FUNCTION ----------------------------------------------
6+
7+
public class App {
8+
public static void main(String[] args) {
9+
System.out.println("\n\t------------ WELCOME TO STUDENT MANAGEMENT SYSTEM ------------\n");
10+
Scanner scanner = new Scanner(System.in);
11+
StudentSystem system = new StudentSystem();
12+
13+
while (true) {
14+
System.out.println("Choose an option:");
15+
System.out.println(" 1. Add Student.");
16+
System.out.println(" 2. Remove Student.");
17+
System.out.println(" 3. Update Student.");
18+
System.out.println(" 4. Search Student by ID.");
19+
System.out.println(" 5. List and Sort Students.");
20+
System.out.println(" 6. Filter Students.");
21+
System.out.println(" 7. Count Total Students.");
22+
System.out.println(" 8. Calculate Average GPA.");
23+
System.out.println(" 9. Display Top 5 Students.");
24+
System.out.println(" 10. Display Failing Students.");
25+
System.out.println(" 11. Generate Summary.");
26+
System.out.println(" 0. Exit Application.");
27+
28+
int choice = InputValidator.inputValidChoice(scanner);
29+
System.out.println();
30+
31+
switch (choice) {
32+
case 1: // Add Student
33+
while (true) {
34+
System.out.println("Choose an option to add student:");
35+
System.out.println(" 1. Add Student from CSV File.");
36+
System.out.println(" 2. Add Student Manually.");
37+
System.out.println(" 0. Exit Add Student.");
38+
39+
int addChoice = InputValidator.inputValidChoice(scanner);
40+
41+
if (addChoice == 0) { // Exit Add Student
42+
System.out.println();
43+
break;
44+
}
45+
46+
switch (addChoice) {
47+
case 1: // Add Student from CSV File
48+
system.mergeStudentSystem(CsvFileHandler.readCsvFile());
49+
break;
50+
51+
case 2: // Add Student Manually
52+
String name = InputValidator.addUniqueName(scanner, system);
53+
int id = InputValidator.addUniqueID(scanner, system);
54+
double gpa = InputValidator.inputValidGPA(scanner);
55+
String year = InputValidator.inputValidYear(scanner);
56+
String department = InputValidator.inputValidDepartment(scanner);
57+
58+
if (year.equals("First") || year.equals("Second")) department = "General";
59+
60+
system.addStudent(name, id, gpa, year, department, false);
61+
break;
62+
63+
default: // Invalid choice
64+
System.out.println("Invalid choice, please try again.");
65+
}
66+
}
67+
break;
68+
69+
case 2: // Remove Student
70+
int removeID = InputValidator.inputValidID(scanner);
71+
system.removeStudentByID(removeID);
72+
break;
73+
74+
case 3: // Update Student
75+
int updateID = InputValidator.inputValidID(scanner);
76+
77+
while (true) {
78+
System.out.println("Choose an option to update:");
79+
System.out.println(" 1. Student's Name.");
80+
System.out.println(" 2. Student's GPA.");
81+
System.out.println(" 3. Student's Year.");
82+
System.out.println(" 4. Student's Department.");
83+
System.out.println(" 0. Exit Update.");
84+
85+
int updateChoice = InputValidator.inputValidChoice(scanner);
86+
if (updateChoice == 0) { // Exit Update
87+
System.out.println();
88+
break;
89+
}
90+
91+
switch (updateChoice) {
92+
case 1: // Update Student's Name
93+
String newName = InputValidator.addUniqueName(scanner, system);
94+
system.updateStudentByID(updateID, newName, -1, null, null);
95+
break;
96+
97+
case 2: // Update Student's GPA
98+
double newGPA = InputValidator.inputValidGPA(scanner);
99+
scanner.nextLine();
100+
system.updateStudentByID(updateID, null, newGPA, null, null);
101+
break;
102+
103+
case 3: // Update Student's Year
104+
String newYear = InputValidator.inputValidYear(scanner);
105+
scanner.nextLine();
106+
system.updateStudentByID(updateID, null, -1, newYear, null);
107+
break;
108+
109+
case 4: // Update Student's Department
110+
String newDepartment = InputValidator.inputValidDepartment(scanner);
111+
scanner.nextLine();
112+
system.updateStudentByID(updateID, null, -1, null, newDepartment);
113+
break;
114+
115+
default: // Invalid choice
116+
System.out.println("Invalid choice, please try again.");
117+
}
118+
}
119+
120+
break;
121+
122+
case 4: // Search Student by ID
123+
int searchID = InputValidator.inputValidID(scanner);
124+
system.searchByID(searchID);
125+
break;
126+
127+
case 5: // List and Sort Students
128+
while (true) {
129+
System.out.println("Output all students in:");
130+
System.out.println(" 1. The Console.");
131+
System.out.println(" 2. A File.");
132+
System.out.println(" 0. Exit List and Sort.");
133+
134+
int outputChoice = InputValidator.inputValidChoice(scanner);
135+
136+
if (outputChoice == 0) { // Exit List and Sort
137+
System.out.println();
138+
break;
139+
}
140+
141+
else if (outputChoice == 1) { // Output in the Console
142+
System.out.print("Enter sorting criteria (GPA, ID, Name, Year): ");
143+
String sortBy = scanner.nextLine();
144+
145+
while (!sortBy.matches("GPA|ID|Name|Year")) {
146+
System.out.println("Invalid input. Please enter a valid sorting criteria.");
147+
System.out.print("Enter sorting criteria (GPA, ID, Name, Year): ");
148+
sortBy = scanner.nextLine();
149+
}
150+
151+
system.listAndSortAllStudents(sortBy);
152+
break;
153+
}
154+
155+
else if (outputChoice == 2) { // Output in a File (CSV)
156+
CsvFileHandler.writeCsvFile(system);
157+
break;
158+
}
159+
160+
else System.out.println("Invalid choice, please try again.\n"); // Invalid choice
161+
}
162+
break;
163+
164+
case 6: // Filter Students
165+
System.out.print("Choose an option to filter (GPA - Year - Department): ");
166+
String filterChoice = scanner.nextLine();
167+
168+
while (!filterChoice.matches("GPA|Year|Department")) {
169+
System.out.println("Invalid input. Please enter a valid year.");
170+
System.out.print("Choose an option to filter (Age - GPA - Year - Department): ");
171+
filterChoice = scanner.nextLine();
172+
}
173+
174+
switch (filterChoice) {
175+
case "GPA":
176+
double filterGPA = InputValidator.inputValidGPA(scanner);
177+
System.out.println();
178+
system.filterByGPA(filterGPA);
179+
break;
180+
181+
case "Year":
182+
String filterYear = InputValidator.inputValidYear(scanner);
183+
System.out.println();
184+
system.filterByYear(filterYear);
185+
break;
186+
187+
case "Department":
188+
String filterDepartment = InputValidator.inputValidDepartment(scanner);
189+
System.out.println();
190+
system.filterByDepartment(filterDepartment);
191+
break;
192+
193+
default:
194+
System.out.println("Invalid choice, please try again.\n");
195+
}
196+
break;
197+
198+
case 7: // Count Total Students
199+
system.countTotalStudents();
200+
break;
201+
202+
case 8: // Calculate Average GPA
203+
system.calculateAverageGPA();
204+
break;
205+
206+
case 9: // Display Top 5 Students
207+
system.displayTop5();
208+
break;
209+
210+
case 10: // Display Failing Students
211+
system.displayFailingStudents();
212+
break;
213+
214+
case 11: // Generate Summary
215+
System.out.println("Choose an option to output generated summary:");
216+
System.out.println(" 1. Output the Summary in the Console.");
217+
System.out.println(" 2. Output the Summary in the Report File.");
218+
System.out.println(" 0. Exit Summary.");
219+
220+
int summaryChoice = InputValidator.inputValidChoice(scanner);
221+
if (summaryChoice == 0) { // Exit Summary
222+
System.out.println();
223+
break;
224+
}
225+
226+
switch (summaryChoice) {
227+
case 1: // Output the Summary in the Console
228+
system.generateSummary();
229+
break;
230+
231+
case 2: // Output the Summary in the Report File
232+
TxtFileHandler.writeTxtFile(system);
233+
break;
234+
235+
default: // Invalid choice
236+
System.out.println("Invalid choice, please try again.");
237+
}
238+
break;
239+
240+
case 0: // Exit Application.
241+
System.out.println("--- Thank you for using Student Management System Application!");
242+
System.out.println("\t--- Exiting system...");
243+
scanner.close();
244+
return;
245+
246+
default: // Invalid choice
247+
System.out.println("Invalid choice, please try again.\n");
248+
}
249+
}
250+
}
251+
}

Student Management System/README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Student Management System
2+
3+
## Overview
4+
5+
The **Student Management System** is a Java-based console application designed to manage student records efficiently. It allows users to perform various operations such as adding, removing, updating, and searching for students. Additionally, it provides features like sorting, filtering, and generating performance summaries. This system is ideal for educational institutions or anyone needing to manage student data in a structured manner.
6+
7+
---
8+
9+
## Features
10+
11+
### 1. **Add Student**
12+
- Add a new student with unique name and ID.
13+
- Input validation ensures valid data for name, ID, age, GPA, year, and department.
14+
15+
### 2. **Remove Student**
16+
- Remove a student by their unique ID.
17+
18+
### 3. **Update Student**
19+
- Update a student's information (name, age, GPA, year, or department) using their ID.
20+
21+
### 4. **Search Student**
22+
- Search for a student by their ID.
23+
24+
### 5. **List and Sort Students**
25+
- List all students sorted by GPA, ID, Name, Year, or Department.
26+
27+
### 6. **Filter Students**
28+
- Filter students by Age, GPA, Year, or Department.
29+
30+
### 7. **Count Total Students**
31+
- Display the total number of students in the system.
32+
33+
### 8. **Calculate Average GPA**
34+
- Calculate and display the average GPA of all students.
35+
36+
### 9. **Display Top 5 Students**
37+
- Display the top 5 performing students based on GPA.
38+
39+
### 10. **Display Failing Students**
40+
- Display students with a GPA less than 2.0.
41+
42+
### 11. **Generate Summary**
43+
- Generate a summary including:
44+
- Average GPA
45+
- Total number of students
46+
- Top 5 performing students
47+
- Failing students
48+
49+
---
50+
51+
## UML Diagram
52+
53+
For a detailed UML class diagram of the project, refer to [UML_Diagram.md](https://github.com/Mohammed-3tef/Student_Management_System/blob/main/UML%20Diagram.md).
54+
55+
---
56+
57+
## Input Validation
58+
59+
The system ensures all inputs are valid:
60+
- **Name**: Only letters and spaces.
61+
- **ID**: Unique positive integer.
62+
- **Age**: Valid age between 0 and 100.
63+
- **GPA**: Valid GPA between 0.0 and 4.0.
64+
- **Year**: Must be one of `First`, `Second`, `Third`, or `Fourth`.
65+
- **Department**: Must be one of `CS`, `IS`, `AI`, `IT`, or `DS`.
66+
67+
---
68+
69+
## Code Structure
70+
71+
### Classes
72+
1. **`Student`**:
73+
- Represents a student with attributes: `name`, `ID`, `age`, `GPA`, `year`, and `department`.
74+
75+
2. **`StudentSystem`**:
76+
- Manages a list of students and provides methods for adding, removing, updating, searching, sorting, filtering, and generating summaries.
77+
78+
### Methods
79+
- **Input Validation**:
80+
- `inputValidName`, `inputValidID`, `inputValidAge`, `inputValidGPA`, `inputValidYear`, `inputValidDepartment`, `inputValidChoice`.
81+
- **Student Operations**:
82+
- `addStudent`, `removeStudentByID`, `updateStudentByID`, `searchByID`, `listAndSortAllStudents`, `filterByAge`, `filterByGPA`, `filterByYear`, `filterByDepartment`, `countTotalStudents`, `calculateAverageGPA`, `displayTop5`, `displayFailingStudents`, `countStudentsByYear`, `generateSummary`.
83+
84+
---
85+
86+
## Example Usage
87+
88+
### Adding a Student
89+
1. Choose option `1` from the menu.
90+
2. Enter the student's name, ID, age, GPA, year, and department.
91+
3. The student will be added to the system.
92+
93+
### Updating a Student
94+
1. Choose option `3` from the menu.
95+
2. Enter the student's ID.
96+
3. Choose the attribute to update (name, age, GPA, year, or department).
97+
4. Enter the new value.
98+
99+
### Generating a Summary
100+
1. Choose option `11` from the menu.
101+
2. The system will display:
102+
- Average GPA
103+
- Total number of students
104+
- Top 5 performing students
105+
- Failing students
106+
107+
---
108+
109+
## Acknowledgments
110+
111+
- Thanks to the Java community for providing excellent resources and libraries.
112+
- Inspired by real-world student management systems.
113+
114+
---
115+
116+
## Enjoy managing your students with ease! 🚀

0 commit comments

Comments
 (0)