-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentGradeManagement.java
More file actions
275 lines (242 loc) · 11.6 KB
/
Copy pathStudentGradeManagement.java
File metadata and controls
275 lines (242 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* ============================================================================
* GRADESPHERE — NEXT-GEN STUDENT PERFORMANCE & ACADEMIC ENGINE (JAVA)
* ============================================================================
* Features:
* 1. Weighted Credit Course Management
* 2. 10-Point CGPA & 4.0 GPA Multi-Scale Calculations
* 3. "What-If" Target GPA Forecaster & Feasibility Solver
* 4. AI Academic Diagnostic & Risk Advisory
* 5. Formatted Academic Transcript & Grade Card Generation
*/
public class StudentGradeManagement {
static class Course {
String code;
String title;
int credits;
double marks;
public Course(String code, String title, int credits, double marks) {
this.code = code;
this.title = title;
this.credits = credits;
this.marks = marks;
}
public String getLetterGrade() {
if (marks >= 90) return "O";
else if (marks >= 80) return "A+";
else if (marks >= 70) return "A";
else if (marks >= 60) return "B+";
else if (marks >= 50) return "B";
else return "RA (Fail)";
}
public int getGradePoint10() {
if (marks >= 90) return 10;
else if (marks >= 80) return 9;
else if (marks >= 70) return 8;
else if (marks >= 60) return 7;
else if (marks >= 50) return 6;
else return 0;
}
public double getGradePoint4() {
if (marks >= 90) return 4.0;
else if (marks >= 80) return 3.7;
else if (marks >= 70) return 3.3;
else if (marks >= 60) return 3.0;
else if (marks >= 50) return 2.0;
else return 0.0;
}
}
static class Student {
String name;
String regNo;
String department;
int semester;
List<Course> courses;
public Student(String name, String regNo, String department, int semester) {
this.name = name;
this.regNo = regNo;
this.department = department;
this.semester = semester;
this.courses = new ArrayList<>();
}
public void addCourse(Course course) {
this.courses.add(course);
}
public int getTotalCredits() {
int total = 0;
for (Course c : courses) {
total += c.credits;
}
return total;
}
public double calculateCGPA10() {
int totalCredits = getTotalCredits();
if (totalCredits == 0) return 0.0;
double weightedPoints = 0;
for (Course c : courses) {
weightedPoints += (c.credits * c.getGradePoint10());
}
return weightedPoints / totalCredits;
}
public double calculateGPA4() {
int totalCredits = getTotalCredits();
if (totalCredits == 0) return 0.0;
double weightedPoints = 0;
for (Course c : courses) {
weightedPoints += (c.credits * c.getGradePoint4());
}
return weightedPoints / totalCredits;
}
public double getAveragePercentage() {
if (courses.isEmpty()) return 0.0;
double sum = 0;
for (Course c : courses) {
sum += c.marks;
}
return sum / courses.size();
}
public String getAcademicStanding() {
int arrears = 0;
for (Course c : courses) {
if (c.marks < 50) arrears++;
}
if (arrears > 0) return "Academic Warning (" + arrears + " Arrears)";
double cgpa = calculateCGPA10();
if (cgpa >= 8.5) return "Dean's Honor List (Distinction)";
else if (cgpa >= 7.5) return "First Class with Distinction";
else if (cgpa >= 6.5) return "First Class";
else return "Second Class";
}
public void printTranscript() {
System.out.println("\n==========================================================================");
System.out.println(" GRADESPHERE — OFFICIAL ACADEMIC TRANSCRIPT ");
System.out.println("==========================================================================");
System.out.printf("Student Name: %-30s Register No: %s\n", name, regNo);
System.out.printf("Department : %-30s Semester : %d\n", department, semester);
System.out.println("--------------------------------------------------------------------------");
System.out.printf("%-10s %-32s %-8s %-7s %-8s %-10s\n", "CODE", "COURSE TITLE", "CREDITS", "MARKS", "GRADE", "PTS (10)");
System.out.println("--------------------------------------------------------------------------");
for (Course c : courses) {
System.out.printf("%-10s %-32s %-8d %-7.1f %-8s %-10d\n",
c.code,
c.title.length() > 30 ? c.title.substring(0, 27) + "..." : c.title,
c.credits,
c.marks,
c.getLetterGrade(),
c.getGradePoint10());
}
System.out.println("--------------------------------------------------------------------------");
System.out.printf("Total Credits Earned : %d\n", getTotalCredits());
System.out.printf("Cumulative GPA (10.0): %.2f / 10.0\n", calculateCGPA10());
System.out.printf("Cumulative GPA (4.0) : %.2f / 4.0\n", calculateGPA4());
System.out.printf("Average Percentage : %.2f%%\n", getAveragePercentage());
System.out.printf("Academic Standing : %s\n", getAcademicStanding());
System.out.println("==========================================================================\n");
}
public void printAIDiagnostics() {
System.out.println("\n--- [GRADESPHERE AI STUDY DIAGNOSTICS & ADVISOR] ---");
if (courses.isEmpty()) {
System.out.println("No course data available.");
return;
}
Course lowest = courses.get(0);
Course highest = courses.get(0);
for (Course c : courses) {
if (c.marks < lowest.marks) lowest = c;
if (c.marks > highest.marks) highest = c;
}
System.out.printf(">> Top Mastery Area : %s (%s) with %.1f Marks\n", highest.title, highest.code, highest.marks);
System.out.printf(">> Primary Risk Area: %s (%s) with %.1f Marks\n", lowest.title, lowest.code, lowest.marks);
if (lowest.marks < 60) {
System.out.println(">> Action Required : CRITICAL! Allocate 6-8 hrs/week on " + lowest.title);
} else {
System.out.println(">> Action Required : Maintain steady revision pace across all modules.");
}
System.out.println("----------------------------------------------------\n");
}
public void simulateTargetGPA(double targetGPA, int remainingCredits) {
System.out.println("\n--- [\"WHAT-IF\" TARGET FORECASTER] ---");
int currentCredits = getTotalCredits();
double currentCGPA = calculateCGPA10();
int totalFutureCredits = currentCredits + remainingCredits;
double requiredTotalPoints = targetGPA * totalFutureCredits;
double currentPoints = currentCredits * currentCGPA;
double requiredFutureGPA = (requiredTotalPoints - currentPoints) / remainingCredits;
System.out.printf("Current CGPA : %.2f (over %d credits)\n", currentCGPA, currentCredits);
System.out.printf("Target Desired CGPA: %.2f\n", targetGPA);
System.out.printf("Upcoming Credits : %d\n", remainingCredits);
System.out.printf("Required Future GPA: %.2f / 10.0\n", requiredFutureGPA);
if (requiredFutureGPA > 10.0) {
System.out.println(">> Verdict: MATHEMATICALLY OUT OF REACH (Exceeds max 10.0 GP).");
} else if (requiredFutureGPA <= currentCGPA) {
System.out.println(">> Verdict: COMFORTABLY ACHIEVABLE with your current pace!");
} else {
System.out.println(">> Verdict: ACHIEVABLE WITH DEDICATED EFFORT (Aim for >" + (int)(requiredFutureGPA * 10) + "% in remaining exams).");
}
System.out.println("-------------------------------------\n");
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Student student = new Student("Alex Morgan", "717823F101", "Computer Science & Engineering", 6);
student.addCourse(new Course("CS601", "Cloud Computing Architecture", 4, 92));
student.addCourse(new Course("CS602", "Internet of Things (IoT)", 4, 88));
student.addCourse(new Course("CS603", "Artificial Intelligence & ML", 3, 85));
student.addCourse(new Course("CS604", "Full Stack Web Development", 4, 90));
student.addCourse(new Course("CS605", "Compiler Design & Theory", 3, 68));
student.addCourse(new Course("CS606", "Mobile Application Lab", 2, 95));
while (true) {
System.out.println("=================================================");
System.out.println(" GRADESPHERE — STUDENT PERFORMANCE STUDIO ");
System.out.println("=================================================");
System.out.println("1. View Official Academic Transcript");
System.out.println("2. Run AI Performance Diagnostics");
System.out.println("3. Run \"What-If\" Target GPA Simulator");
System.out.println("4. Add New Custom Course");
System.out.println("5. Exit");
System.out.print("Enter your choice (1-5): ");
if (!sc.hasNextInt()) {
break;
}
int choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
student.printTranscript();
break;
case 2:
student.printAIDiagnostics();
break;
case 3:
System.out.print("Enter Desired Target CGPA (e.g. 8.8): ");
double target = sc.nextDouble();
System.out.print("Enter Remaining Upcoming Credits (e.g. 8): ");
int remCredits = sc.nextInt();
student.simulateTargetGPA(target, remCredits);
break;
case 4:
System.out.print("Enter Course Code: ");
String code = sc.nextLine();
System.out.print("Enter Course Title: ");
String title = sc.nextLine();
System.out.print("Enter Credits (1-5): ");
int cred = sc.nextInt();
System.out.print("Enter Marks (0-100): ");
double marks = sc.nextDouble();
student.addCourse(new Course(code, title, cred, marks));
System.out.println("Course added successfully!\n");
break;
case 5:
System.out.println("Thank you for using GradeSphere. Exiting...");
sc.close();
return;
default:
System.out.println("Invalid choice. Please choose 1-5.\n");
}
}
sc.close();
}
}