-
Notifications
You must be signed in to change notification settings - Fork 0
/
SMS.cpp
857 lines (749 loc) · 25.5 KB
/
SMS.cpp
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
// #characters
#include <array>
#include <string>
#include <vector>
#include <iostream>
// #Maths ~ Fn
#include <cmath>
#include <chrono>
#include <thread>
//System Functions
#include <cstdlib>
#include <stdlib.h>
// #File System
#include <fstream>
#include <sstream>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
using namespace std; /// MASRKAI
/////////////////////////////////
const int MAX_COURSES = 100; // Maximum number of courses per student
const int MAX_STUDENTS = 10000;
void ClearTerminal() { // Ergonomics
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
} /// MASRKAI
/////////////////////////////////
#ifdef _WIN32 //--System Integrity & Cross platform support
#include <windows.h>
#define RESET_COLOR \
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), \
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
#else
// ANSI code
#define RESET_COLOR "\033[0m"
#define RED "\033[31m" // Defining Red
#define GREEN "\033[32m" // Defining Green
#define YELLOW "\033[33m" // Defining Yellow
#define BLUE "\033[34m" // Defining Blue
#define MAGENTA "\033[35m" // Defining Magenta
#define CYAN "\033[36m" // Defining Cyan
#define BOLD "\033[1m" // Defining Bold
#endif
/// MASRKAI
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Function to print colored and bold text
void printColor(const string &color, const string &text, bool bold = false) {
cout << (bold ? BOLD : "") << color << text << RESET_COLOR;
} /// MASRKAI
////////////////////////////////////////////////////////////////////////////////////////
class LimiterBase {
protected:
virtual void drawFrame(char c1, char c2, char c3, int loops,int milliseconds) {
for (int i = 0; i <= loops; ++i) {
cout << " " << c1;
this_thread::sleep_for(chrono::milliseconds(milliseconds));
cout << "\b\b"; // Erase the character
cout.flush();
cout << " " << c2;
this_thread::sleep_for(chrono::milliseconds(milliseconds));
cout << "\b\b"; // Erase the character
cout.flush();
cout << " " << c3;
this_thread::sleep_for(chrono::milliseconds(milliseconds));
cout << "\b\b"; // Erase the character
// ! Erasing animation
this_thread::sleep_for(chrono::milliseconds(milliseconds));
cout << "\b\b";
cout.flush();}
}
public:
virtual void start() = 0;
};
class LimiterS {
protected:
virtual void drawFrame(char c1, char c2, char c3, int loops, int Secs) {
for (int i = 0; i <= loops; ++i) {
cout << " " << c1;
this_thread::sleep_for(chrono::milliseconds(Secs));
cout << "\b\b"; // Erase the character
cout.flush();
cout << " " << c2;
this_thread::sleep_for(chrono::milliseconds(Secs));
cout << "\b\b"; // Erase the character
cout.flush();
cout << " " << c3;
this_thread::sleep_for(chrono::milliseconds(Secs));
cout << "\b\b"; // Erase the character
// ! Erasing animation
this_thread::sleep_for(chrono::milliseconds(Secs));
cout << "\b\b";
cout.flush(); }
this_thread::sleep_for(chrono::milliseconds(Secs)); }
public:
virtual void start() = 0;
};
// MASRKAI
///////////////////////////////////////////////////////////////////////////////////////////
class Limiter : public LimiterBase {
public:
void start() override {
printColor(RED, "Limiter is Active", true);
drawFrame('-', '/', '|', 9, 80);
ClearTerminal();
}
};
class Contributors : public LimiterS {
public:
void start() override {
printColor(GREEN, " Contributors", true);
drawFrame('-', '/', '|', 6, 200);
ClearTerminal();
}
};
// Course class to store course information
class Course {
private:
string courseId;
string courseName;
double creditHours;
double percentageGrade;
public:
Course(const string &courseId, const string &courseName, double creditHours)
: courseId(courseId), courseName(courseName), creditHours(creditHours),
percentageGrade(-1) {}
void setGrade(double percentageGrade) {
this->percentageGrade = percentageGrade;
}
double getGrade() const { return percentageGrade; }
string getCourseId() const { return courseId; }
double getCreditHours() const { return creditHours; }
string getLetterGrade() const {
if (percentageGrade >= 97 && percentageGrade <= 100)
return "A+";
else if (percentageGrade >= 93 && percentageGrade < 97)
return "A";
else if (percentageGrade >= 89 && percentageGrade < 93)
return "A-";
else if (percentageGrade >= 84 && percentageGrade < 89)
return "B+";
else if (percentageGrade >= 80 && percentageGrade < 84)
return "B";
else if (percentageGrade >= 76 && percentageGrade < 80)
return "B-";
else if (percentageGrade >= 73 && percentageGrade < 76)
return "C+";
else if (percentageGrade >= 70 && percentageGrade < 73)
return "C";
else if (percentageGrade >= 67 && percentageGrade < 70)
return "C-";
else if (percentageGrade >= 64 && percentageGrade < 67)
return "D+";
else if (percentageGrade >= 60 && percentageGrade < 64)
return "D";
else if (percentageGrade < 0 || percentageGrade > 100)
return "null"; // If percentage is negative or greater than 100, return
// "null"
else
return "F";
}
double getGradePoints() const {
string letterGrade = getLetterGrade();
if (letterGrade == "A+" || letterGrade == "A")
return 4.0;
else if (letterGrade == "A-")
return 3.7;
else if (letterGrade == "B+")
return 3.3;
else if (letterGrade == "B")
return 3.0;
else if (letterGrade == "B-")
return 2.7;
else if (letterGrade == "C+")
return 2.3;
else if (letterGrade == "C")
return 2.0;
else if (letterGrade == "C-")
return 1.7;
else if (letterGrade == "D+")
return 1.3;
else if (letterGrade == "D")
return 1.0;
else if (letterGrade == "F")
return 0.0;
else
return 0.0; // Return 0.0 for "null" grade
}
void displayInfo() const {
cout << "Course ID: " << courseId << "\tCourse Name: " << courseName
<< "\tCredit Hours: " << creditHours << "\tGrade: " << getLetterGrade()
<< " (" << getGradePoints() << " points)" << endl;
}
void editCourseInfo(const string &newCourseName, double newCreditHours) {
courseName = newCourseName;
creditHours = newCreditHours;
cout << "Course details updated." << endl;
}
};
// User class to store user information
class User {
protected:
int id;
string name;
public:
User(int id, const string &name) : id(id), name(name) {}
void displayInfo() const {
cout << "ID: " << id << "\tName: " << name << endl;
}
int getId() const { return id; }
string getName() const { return name; }
};
// Student class derived from User
class Student : public User {
private:
Course *courses[MAX_COURSES]; // Array to store courses
int courseCount;
public:
friend class Administrator;
Student(int id, const string &name) : User(id, name), courseCount(0) {}
void addCourse(const string &courseId, const string &courseName,
double creditHours) {
if (courseCount < MAX_COURSES) {
courses[courseCount++] = new Course(courseId, courseName, creditHours);
}
}
void removeCourse(const string &courseId) {
for (int i = 0; i < courseCount; ++i) {
if (courses[i]->getCourseId() == courseId) {
delete courses[i];
for (int j = i; j < courseCount - 1; ++j) {
courses[j] = courses[j + 1];
}
courseCount--;
cout << "Course with ID " << courseId << " removed for student with ID "
<< getId() << "." << endl;
return;
}
}
cout << "Course with ID " << courseId << " not found for student with ID "
<< getId() << "." << endl;
}
void inputGrade(const string &courseId, double percentageGrade) {
for (int i = 0; i < courseCount; ++i) {
if (courses[i]->getCourseId() == courseId) {
courses[i]->setGrade(percentageGrade);
cout << "Grade added for course ID " << courseId
<< " for student with ID " << getId() << "." << endl;
return;
}
}
cout << "Course with ID " << courseId << " not found for student with ID "
<< getId() << "." << endl;
}
double calculateGPA() const {
double totalPoints = 0;
double totalCreditHours = 0;
for (int i = 0; i < courseCount; ++i) {
if (courses[i]->getGrade() >=
0) { // Only consider graded courses for GPA calculation
totalPoints +=
courses[i]->getGradePoints() * courses[i]->getCreditHours();
totalCreditHours += courses[i]->getCreditHours();
}
}
if (totalCreditHours > 0) {
return totalPoints / totalCreditHours;
}
return 0; // Return 0 if no courses
}
void displayCourses() const {
for (int i = 0; i < courseCount; ++i) {
courses[i]->displayInfo();
}
}
void editUserInfo(const string &newName) {
name = newName;
cout << "\nStudent details updated." << endl;
}
void editCourseInfo(const string &courseId, const string &newCourseName,
double newCreditHours) {
for (int i = 0; i < courseCount; ++i) {
if (courses[i]->getCourseId() == courseId) {
courses[i]->editCourseInfo(newCourseName, newCreditHours);
cout << "Course details updated for student with ID " << getId() << "."
<< endl;
return;
}
}
cout << "Course with ID " << courseId << " not found for student with ID "
<< getId() << "." << endl;
}
int getCourseIndex(const string &courseId) const {
for (int i = 0; i < courseCount; ++i) {
if (courses[i]->getCourseId() == courseId) {
return i;
}
}
return -1; // Course not found
}
~Student() {
for (int i = 0; i < courseCount; ++i) {
delete courses[i];
}
}
};
// Administrator class derived from User
class Administrator : public User {
private:
pair<string, pair<string, double>>
courseInfo[MAX_COURSES]; // Array to store course information linked with
// course ID
Student *students[MAX_STUDENTS];
int studentCount;
int courseInfoCount;
public:
Administrator(int id, const string &name)
: User(id, name), studentCount(0), courseInfoCount(0) {}
void addCourseInfo(const string &courseId, const string &courseName,
double creditHours) {
if (courseInfoCount < MAX_COURSES) {
courseInfo[courseInfoCount++] =
make_pair(courseId, make_pair(courseName, creditHours));
}
}
pair<string, double> getCourseInfo(const string &courseId) {
for (int i = 0; i < courseInfoCount; ++i) {
if (courseInfo[i].first == courseId) {
return courseInfo[i].second;
}
}
return make_pair("", 0.0); // Return empty pair if course not found
}
void addStudent(int id, const string &name) {
for (int i = 0; i < studentCount; ++i) {
if (students[i]->getId() == id) {
printColor(RED, "Duplicated id (This data won't be saved) \n", true);
}
}
if (studentCount < MAX_STUDENTS) {
students[studentCount++] = new Student(id, name);
printColor(GREEN, "Student added with ID ", true);
cout << id;
printColor(BLUE, ".\nStudent name is ", true);
cout << name << "." << endl;
}
}
void removeStudent(int id) {
for (int i = 0; i < studentCount; ++i) {
if (students[i]->getId() == id) {
delete students[i];
for (int j = i; j < studentCount - 1; ++j) {
students[j] = students[j + 1];
}
studentCount--;
cout << "Student with ID " << id << " removed." << endl;
return;
}
}
cout << "Student with ID " << id << " not found." << endl;
}
void removeStudentFromCourse(int studentId, const string &courseId) {
for (int i = 0; i < studentCount; ++i) {
if (students[i]->getId() == studentId) {
students[i]->removeCourse(courseId);
return;
}
}
cout << "Student with ID " << studentId << " not found." << endl;
}
Student *findStudent(int id) {
for (int i = 0; i < studentCount; ++i) {
if (students[i]->getId() == id) {
return students[i];
}
}
return nullptr;
}
void addCourseToStudent(int studentId, const string &courseId) {
Student *student = findStudent(studentId);
if (student) {
pair<string, double> courseInfo = getCourseInfo(courseId);
if (!courseInfo.first.empty()) {
student->addCourse(courseId, courseInfo.first, courseInfo.second);
cout << "Course " << courseInfo.first << " added for student ID "
<< studentId << "." << endl;
} else {
cout << "Course with ID " << courseId << " not found." << endl;
}
} else {
cout << "Student with ID " << studentId << " not found." << endl;
}
}
void displayStudents() const {
for (int i = 0; i < studentCount; ++i) {
students[i]->displayInfo();
students[i]->displayCourses();
cout << "GPA: " << students[i]->calculateGPA() << endl;
}
}
// Bubble sort implementation to rank students based on GPA
void rankStudents() {
for (int i = 0; i < studentCount - 1; ++i) {
for (int j = 0; j < studentCount - i - 1; ++j) {
if (students[j]->calculateGPA() < students[j + 1]->calculateGPA()) {
// Swap students
Student *temp = students[j];
students[j] = students[j + 1];
students[j + 1] = temp;
}
}
}
cout << "\n Rank\tStudent ID\tStudent Name\tGPA" << endl;
cout << "------------------------------------------------" << endl;
for (int i = 0; i < studentCount; ++i) {
cout << " " << i + 1 << "\t " << students[i]->getId() << "\t"
<< students[i]->getName() << "\t";
cout << students[i]->calculateGPA() << endl;
}
}
void addCourse(const string &courseId, const string &courseName,
double creditHours) {
addCourseInfo(courseId, courseName, creditHours);
cout << "Course " << courseName << " added with ID " << courseId << "."
<< endl;
}
void removeCourse(const string &courseId) {
// Remove course from courseInfo
int indexToRemove = -1;
for (int i = 0; i < courseInfoCount; ++i) {
if (courseInfo[i].first == courseId) {
indexToRemove = i;
break;
}
}
if (indexToRemove != -1) {
for (int i = indexToRemove; i < courseInfoCount - 1; ++i) {
courseInfo[i] = courseInfo[i + 1];
}
courseInfoCount--;
}
// Remove course from all students
for (int i = 0; i < studentCount; ++i) {
students[i]->removeCourse(courseId);
}
cout << "Course with ID " << courseId << " removed." << endl;
}
void removeAllStudents() {
for (int i = 0; i < studentCount; ++i) {
delete students[i];
}
studentCount = 0;
cout << "All students removed." << endl;
}
void removeAllCourses() {
courseInfoCount = 0;
for (int i = 0; i < studentCount; ++i) {
students[i]->removeCourse(courseInfo[i].first);
}
cout << "All courses removed." << endl;
}
// Edit course details
void editCourseDetails(const string &courseId, const string &newCourseName,
double newCreditHours) {
for (int i = 0; i < courseInfoCount; ++i) {
if (courseInfo[i].first == courseId) {
// Update course info
courseInfo[i].second.first = newCourseName;
courseInfo[i].second.second = newCreditHours;
// Update course details for all enrolled students
for (int j = 0; j < studentCount; ++j) {
students[j]->editCourseInfo(courseId, newCourseName, newCreditHours);
}
cout << "\nCourse details updated." << endl;
return;
}
}
cout << "Course with ID " << courseId << " not found." << endl;
}
// Display enrolled students for a specific course
void displayEnrolledStudents(const string &courseId) const {
cout << "Enrolled students for course with ID " << courseId << ":" << endl;
bool found = false;
for (int i = 0; i < studentCount; ++i) {
if (students[i]->getCourseIndex(courseId) != -1) {
found = true;
cout << "Student ID: " << students[i]->getId()
<< "\tName: " << students[i]->getName() << endl;
}
}
if (!found) {
printColor(RED, "No students enrolled in course with ID ", true);
}
}
void readDataFromFile(const string &filename) {
ifstream infile(filename);
if (infile.is_open()) {
string line;
while (getline(infile, line)) {
istringstream iss(line);
char type;
iss >> type;
if (type == 'S') {
int id;
string name;
iss >> id;
getline(iss, name);
addStudent(id, name);
} else if (type == 'C') {
string courseId, courseName;
double creditHours;
iss >> courseId >> courseName >> creditHours;
addCourseInfo(courseId, courseName, creditHours);
} else if (type == 'E') {
int studentId;
string courseId;
iss >> studentId >> courseId;
addCourseToStudent(studentId, courseId);
} else if (type == 'G') {
int studentId;
string courseId;
double percentageGrade;
iss >> studentId >> courseId >> percentageGrade;
findStudent(studentId)->inputGrade(courseId, percentageGrade);
}
}
infile.close();
} else {
cerr << "Unable to open file for reading.";
}
}
void writeDataToFile(const string &filename, Administrator &admin) {
ofstream outfile(filename);
if (outfile.is_open()) {
// Write course info
for (int i = 0; i < admin.courseInfoCount; ++i) {
outfile << "C " << admin.courseInfo[i].first << " "
<< admin.courseInfo[i].second.first << " "
<< admin.courseInfo[i].second.second << endl;
}
// Write students and their courses
for (int i = 0; i < admin.studentCount; ++i) {
outfile << "S " << admin.students[i]->getId() << " "
<< admin.students[i]->getName() << endl;
for (int j = 0; j < admin.students[i]->courseCount; ++j) {
outfile << "E " << admin.students[i]->getId() << " "
<< admin.students[i]->courses[j]->getCourseId() << endl;
double grade = admin.students[i]->courses[j]->getGrade();
if (grade >= 0) {
outfile << "G " << admin.students[i]->getId() << " "
<< admin.students[i]->courses[j]->getCourseId() << " "
<< grade << endl;
}
}
}
outfile.close();
cout << "Data successfully written to file: " << filename << endl;
} else {
cerr << "Unable to open file for writing: " << filename << endl;
}
}
~Administrator() {
for (int i = 0; i < studentCount; ++i) {
delete students[i];
}
}
};
void menu_of_options() {
printColor(GREEN, "\n***** Welcome to Student Managment System *****\n\n",
true);
printColor(BLUE, "1. Add Student\n", false);
printColor(BLUE, "2. Add Course\n", false);
printColor(BLUE, "3. Enroll Student To A Course\n", false);
printColor(BLUE, "4. Input Grade for Course\n\n", false);
printColor(YELLOW, "6. Edit Course Details\n", false);
printColor(YELLOW, "7. Find Specific Student\n", false);
printColor(YELLOW, "5. Edit Student Details\n", false);
printColor(YELLOW, "8. Display Enrolled Students for a Specific Course\n",false);
printColor(YELLOW, "9. Display Detailed Students info\n", false);
printColor(YELLOW, "10. Rank Students by GPA\n\n", false);
printColor(RED, "11. Remove Course\n", false);
printColor(RED, "12. Remove Student\n", false);
printColor(RED, "13. Remove Student from Course\n", false);
printColor(RED, "14. Remove All Students\n", false);
printColor(RED, "15. Remove All Courses\n", false);
printColor(RED, "16. Clear Terminal\n", true);
printColor(RED, "17. Exit\n", true);
cout << "\n";
}
int main() {
class Contributors CC;
Administrator admin1(1, "Program Director");
admin1.readDataFromFile(
"C:\\Users\\awaad\\OneDrive\\Documents\\PROJECT\\project.txt");
CC.start();
int choice, studentId;
double grade;
string studentName, courseId, newCourseName;
double newCreditHours;
do {
menu_of_options();
cout << "Enter your choice: ";
cin >> choice;
if (cin.fail()) {
cin.clear();
cin.ignore(256, '\n');
continue;
}
switch (choice) {
case 1:
cout << "Enter Student ID: ";
cin >> studentId;
cin.ignore();
cout << "Enter Student Name(First Name, Last Name): ";
getline(cin, studentName);
admin1.addStudent(studentId, studentName);
break;
case 2:
cout << "Enter Course ID: ";
cin >> courseId;
cin.ignore();
cout << "Enter Course Name: ";
getline(cin, studentName);
cout << "Enter Credit Hours: ";
double creditHours;
cin >> creditHours;
admin1.addCourse(courseId, studentName, creditHours);
break;
case 3:
cout << "Enter Student ID: ";
cin >> studentId;
cin.ignore();
if (admin1.findStudent(studentId)) {
cout << "Enter Course ID: ";
getline(cin, courseId);
admin1.addCourseToStudent(studentId, courseId);
} else {
cout << "Student with ID " << studentId << " not found." << endl;
}
break;
case 4:
cout << "Enter Student ID: ";
cin >> studentId;
cin.ignore();
if (admin1.findStudent(studentId)) {
cout << "Enter Course ID: ";
cin >> courseId;
cout << "Enter Grade (Percentage): ";
cin >> grade;
admin1.findStudent(studentId)->inputGrade(courseId, grade);
} else {
cout << "Student with ID " << studentId << " not found." << endl;
}
break;
case 5:
cout << "Enter Student ID to edit details: ";
cin >> studentId;
cin.ignore();
if (admin1.findStudent(studentId)) {
cout << "Enter new Student Name(First Name, Last Name): ";
getline(cin, studentName);
admin1.findStudent(studentId)->editUserInfo(studentName);
} else {
cout << "Student with ID " << studentId << " not found." << endl;
}
break;
case 6:
cout << "Enter Course ID to edit details: ";
cin >> courseId;
cin.ignore();
if (admin1.getCourseInfo(courseId).first != "") {
cout << "Enter new Course Name: ";
getline(cin, newCourseName);
cout << "Enter new Credit Hours: ";
cin >> newCreditHours;
admin1.editCourseDetails(courseId, newCourseName, newCreditHours);
} else {
cout << "Course with ID " << courseId << " not found." << endl;
}
break;
case 7:
cout << "Enter Student ID: ";
cin >> studentId;
{
Student *foundStudent = admin1.findStudent(studentId);
if (foundStudent) {
cout << "Student found:" << endl;
foundStudent->displayInfo();
foundStudent->displayCourses();
cout << "GPA: " << foundStudent->calculateGPA() << endl;
} else {
cout << "Student with ID " << studentId << " not found." << endl;
}
}
break;
case 8:
cout << "Enter Course ID: ";
cin >> courseId;
admin1.displayEnrolledStudents(courseId);
break;
case 9:
admin1.displayStudents();
break;
case 10:
admin1.rankStudents();
break;
case 11:
cout << "Enter Student ID to remove: ";
cin >> studentId;
admin1.removeStudent(studentId);
break;
case 12:
cout << "Enter Course ID to remove: ";
cin >> courseId;
admin1.removeCourse(courseId);
break;
case 13:
cout << "Enter Student ID: ";
cin >> studentId;
cin.ignore();
cout << "Enter Course ID to remove: ";
getline(cin, courseId);
admin1.removeStudentFromCourse(studentId, courseId);
break;
case 14:
admin1.removeAllStudents();
break;
case 15:
admin1.removeAllCourses();
break;
case 16:
ClearTerminal();
break;
case 17:
cout << "Exiting..." << endl;
break;
default:
cout << "Invalid choice! please try again" << endl;
break;
}
} while (choice != 17);
admin1.writeDataToFile(
"C:\\Users\\awaad\\OneDrive\\Documents\\PROJECT\\project.txt", admin1);
return 0;
}