forked from koko89090k-design/Student_Management_System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
90 lines (89 loc) · 2.25 KB
/
Copy pathmain.cpp
File metadata and controls
90 lines (89 loc) · 2.25 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
#include<bits/stdc++.h>
#include "course.h"
#include "student.h"
#include"utils.h"
#include "storage.h"
#include"color.h"
using namespace std;
int main(){
vector<Student>students;
vector <Course> courses;
string id;
int n;
string filename="database.txt";
while(true){
cout<<CYAN<<"====== MENU ======"<<RESET<<'\n';
cout<<CYAN<<"press 1 to add a student"<<RESET<<'\n' ;
cout<<CYAN<<"press 2 to add a Course"<<RESET<<'\n' ;
cout<<CYAN<<"press 3 to record a grade"<<RESET<<'\n' ;
cout<<CYAN<<"press 4 to print a students information"<<RESET<<'\n' ;
cout<<CYAN<<"press 5 to print a students gpa"<<RESET<<'\n';
cout<<CYAN<<"press 6 for course report"<<RESET<<'\n';
cout<<CYAN<<"press 7 to save data to database"<<RESET<<'\n';
cout<<CYAN<<"press 8 to load data from database"<<RESET<<'\n';
cout<<CYAN<<"press 9 export course CSV"<<RESET<<'\n' ;
cout<<CYAN<<"press 0 to exit"<<RESET<<'\n';
cin>>n;
if(n==0){
break;
}
switch (n)
{
case 1:
addStudent(students);
break;
case 2:
addCourse(courses);
break;
case 3:
recordGrade(courses,students);
break;
case 4: {
cout<<CYAN<<"enter student id"<<RESET<<'\n';
cin>>id;
auto it=findStudentById(students,id);
if(it==0){
cout<<RED<<"student not found"<<RESET<<'\n';
}
else{
printStudent(*it);
}
break;
}
case 5:
printStudentGPA(students,courses);
break;
case 6:
printCourseReport(courses,students);
break;
case 7:{
saveDatabase(students,courses,filename);
cout<<GREEN<<"Database saved"<<RESET<<'\n';
break;
}
case 8:{
loadDatabase(students,courses,filename);
cout<<GREEN<<"Database loaded"<<RESET<<'\n';
break ;
}
case 9:{
string cid;
cout<<CYAN<<"enter course id: "<<RESET<<'\n';
cin>>cid;
Course*c=findCourseById(courses,cid);
if(c==nullptr){
cout<<RED<<"Course not found!"<<RESET<<'\n';
}
else{
exportCourseCSV(c,students);
cout<<GREEN<<"CVS exported"<<RESET<<'\n';
}
break;
}
default:
cout<<RED<<"invalid number pick another one from the menu"<<RESET<<'\n';
break;
}
}
return 0;
}