-
Notifications
You must be signed in to change notification settings - Fork 1
/
Interface.h
471 lines (461 loc) · 11.5 KB
/
Interface.h
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
#pragma once
#include<iostream>
#include<fstream>
#include"AcademicOfficer.h"
#include"Teacher.h"
#include"Student.h"
#include"Courses.h"
#include"Registration.h"
#include<stdlib.h>
#include<string>
using namespace std;
Courses ListOfCourses[100];
Student ListOfStudents[100];
Registration listOfReg[100];
int counterStudent = 0;
int countreg;
int counter = 0;
bool Compare(string key, int &index) {
for (int i = 0; i < counter; ++i)
if (key == ListOfCourses[i].GetCode()) {
index = i;
return true;
}
return false;
}
Courses AddCourse()
{
string cc, cn;
cout << "Enter course code: ";
cin >> cc;
cout << "Enter course name: ";
cin >> cn;
Courses Course(cc,cn);
cout << "\nCourse added\n" << "Course Code: " << cc << "\nCourse Name: " << cn << "\nCurrent No of Sections: " << Course.GetSections() << endl;
ofstream outfile;
outfile.open("Courses.txt", std::ios_base::app);
outfile << Course.GetCode() << " ";
outfile << Course.GetName() << endl;
outfile.close();
return Course;
}
void RemoveCourse()
{
string key;
int index;
cout << "Enter course code to remove: ";
cin >> key;
if(Compare(key,index)){
for (int i = index; i < counter; ++i)
ListOfCourses[i] = ListOfCourses[i + 1];
counter--;
ofstream outfile;
outfile.open("Courses.txt");
for (int i = 0; i < counter; ++i) {
outfile << ListOfCourses[i].GetCode() << " ";
outfile << ListOfCourses[i].GetName() << endl;
}
outfile.close();
}
else
cout << "Invalid Course code " << endl;
}
void UpdateCourseInfo()
{
int index;
string key;
cout << "Enter course code: ";
cin >> key;
if (Compare(key, index)) {
string cc, cn;
cout << "Enter new course code: ";
cin >> cc;
cout << "Enter new course name: ";
cin >> cn;
ListOfCourses[index].SetCode(cc);
ListOfCourses[index].Setname(cn);
cout << "\nCourse Updated\n" << "Course Code: " << cc << "\nCourse Name: " << cn << endl;
ofstream outfile;
outfile.open("Courses.txt");
int i = 0;
while (i < counter) {
outfile << ListOfCourses[i].GetCode() << " ";
outfile << ListOfCourses[i].GetName() << endl;
++i;
}
outfile.close();
}
else
cout << "Invalid course code" << endl;
}
void AddSection()
{
int index;
string key;
char s;
cout << "Enter course code: ";
cin >> key;
if (Compare(key, index)) {
cout << "Enter section ";
cin >> s;
ListOfCourses[index].SetSection(s);
}
else
cout << "Invalid course code" << endl;
}
void RegisterCourse(string id)
{
int index;
string key;
cout << "Enter course code: ";
cin >> key;
if (Compare(key, index)) {
listOfReg[countreg].Setcourse(ListOfCourses[index]);
listOfReg[countreg].SetStudent(id);
ofstream outfile;
outfile.open("Registeration.txt", std::ios_base::app);
outfile << listOfReg[countreg].Getcourse().GetCode() << " ";
outfile << listOfReg[countreg].Getstudent() << endl;
outfile.close();
countreg++;
cout << "Course registered successfully " << endl;
}
else
cout << "Invalid code" << endl;
}
void ViewTranscript(string id)
{
float total=0;
double cgpa=0;
for (int i = 0; i < countreg; ++i) {
if (listOfReg[i].Getstudent() == id)
{
total++;
cout << "Course: " << listOfReg[i].Getcourse().GetCode() << " " << listOfReg[i].Getcourse().GetName() << " Grade: " << listOfReg[i].GetGrade()<<endl;
if (listOfReg[i].GetGrade() == 'A')
cgpa = cgpa+ 4;
if (listOfReg[i].GetGrade() == 'B')
cgpa = cgpa + 3;
if (listOfReg[i].GetGrade() == 'C')
cgpa = cgpa + 2;
if(listOfReg[i].GetGrade()=='D')
cgpa = cgpa + 1;
}
}
if (total == 0)
cout << "Student no registered in any course!!!!!" << endl;
else {
cgpa = cgpa / (total * 3);
cout << "CGPA is: " << cgpa << endl;
}
}
void SetEvaluations()
{
int index;
string key;
char s;
cout << "Enter course code: ";
cin >> key;
int i=-1;
if (Compare(key, index)) {
while (i != 0) {
cout << "\n\t\t\tEnter <1> Set Assignment Weights"
<< "\n\t\t\tEnter <2> Set Quiz Weights"
<< "\n\t\t\tEnter <3> Set Mids Weights"
<< "\n\t\t\tEnter <4> Set Finals Weights"
<< "\n\t\t\tEnter <0> To Exit\n";
cout << "\n\n\t\t\tEnter Your Choice: ";
cin >> i;
if (i == 1) {
cout << "Enter Weights: ";
int w;
cin >> w;
ListOfCourses[index].GetMarks().SetWAssign(w);
cout << "Weights updated successfully" << endl;
}
if (i == 2) {
cout << "Enter Weights: ";
int w;
cin >> w;
ListOfCourses[index].GetMarks().SetWQuiz(w);
cout << "Weights updated successfully" << endl;
}
if (i == 3) {
cout << "Enter Weights: ";
int w;
cin >> w;
ListOfCourses[index].GetMarks().SetWMid(w);
cout << "Weights updated successfully" << endl;
}
if (i == 4) {
cout << "Enter Weights: ";
int w;
cin >> w;
ListOfCourses[index].GetMarks().SetWFinals(w);
cout << "Weights updated successfully" << endl;
}
}
}
else
cout << "Invalid course code" << endl;
}
void EnterMarks()
{
int j=-1;
string code,id;
char s;
cout << "Enter course code: ";
cin >> code;
cout << "Enter student ID: ";
cin >> id;
int flag = 0;
for (int i = 0; i < countreg; ++i) {
if (listOfReg[i].Getstudent() == id && listOfReg[i].Getcourse().GetCode() == code) {
while (j != 0) {
cout << "\n\t\t\tEnter <1> Set Assignment Marks"
<< "\n\t\t\tEnter <2> Set Quiz Marks"
<< "\n\t\t\tEnter <3> Set Mids Marks"
<< "\n\t\t\tEnter <4> Set Finals Marks"
<< "\n\t\t\tEnter <0> To Exit\n";
cout << "\n\n\t\t\tEnter Your Choice: ";
cin >> j;
if (j == 1) {
cout << "Enter Marks: ";
int w;
cin >> w;
listOfReg[i].GetMarks().SetAssign(w);
cout << "Marks updated successfully" << endl;
}
if (j == 2) {
cout << "Enter Marks: ";
int w;
cin >> w;
listOfReg[i].GetMarks().SetQuiz(w);
cout << "Marks updated successfully" << endl;
}
if (j == 3) {
cout << "Enter Marks: ";
int w;
cin >> w;
listOfReg[i].GetMarks().SetMid(w);
cout << "Marks updated successfully" << endl;
}
if (j == 4) {
cout << "Enter Marks: ";
int w;
cin >> w;
listOfReg[i].GetMarks().SetFinals(w);
cout << "Marks updated successfully" << endl;
}
}
flag = 1;
}
}
if (flag == 0)
cout << "Invalid combination" << endl;
}
void PerformanceReport()
{
int j = -1;
string code, id;
char s;
cout << "Enter course code: ";
cin >> code;
cout << "Enter student ID: ";
cin >> id;
int flag = 0;
for (int i = 0; i < countreg; ++i) {
if (listOfReg[i].Getstudent() == id && listOfReg[i].Getcourse().GetCode() == code) {
cout << "Assignment Marks: 4" << listOfReg[i].GetMarks().GetAssign() << endl;
cout << "Quiz Marks: 2" << listOfReg[i].GetMarks().Getquiz() << endl;
cout << "Mids Marks: 1" << listOfReg[i].GetMarks().Getmid() << endl;
cout << "Finals Marks: 7" << listOfReg[i].GetMarks().Getfinals() << endl;
flag = 1;
}
}
if (flag == 0)
cout << "Invalid combination" << endl;
}
void AcademicOfficer()
{
system("CLS");
cout << "\t\t\t-----------------------------------------\n";
cout << "\t\t\t University Management System\n";
cout << "\t\t\t-----------------------------------------\n";
cout << "\t\t\tAcademic Officer Portal\n";
int i = -1;
while (i!=0)
{
cout << "\n\t\t\tEnter <1> Add Course"
<< "\n\t\t\tEnter <2> Remove Course"
<< "\n\t\t\tEnter <3> Update Course Information"
<< "\n\t\t\tEnter <4> Add Section to Course"
<< "\n\t\t\tEnter <0> To Exit\n";
cout << "\n\n\t\t\tEnter Your Choice: ";
cin >> i;
if(i==1){
ListOfCourses[counter++] = AddCourse();
}
else if(i==2){
RemoveCourse();
}
else if(i==3){
UpdateCourseInfo();
}
else if(i==4){
AddSection();
}
else
cout << "\nWRONG CHOICE!!!\nTRY AGAIN";
}
}
void Teacher()
{
system("CLS");
cout << "\t\t\t-----------------------------------------\n";
cout << "\t\t\t University Management System\n";
cout << "\t\t\t-----------------------------------------\n";
cout << "\t\t\t Teacher Portal\n";
int i = -1;
while (i != 0)
{
cout << "\n\t\t\tEnter <1> Set Evaluations"
<< "\n\t\t\tEnter <2> Enter Marks"
<< "\n\t\t\tEnter <3> View Performance Report"
<< "\n\t\t\tEnter <0> To Exit\n";
cout << "\n\n\t\t\tEnter Your Choice: ";
cin >> i;
if (i == 1)
SetEvaluations();
else if (i == 2)
EnterMarks();
else if (i == 3)
PerformanceReport();
else if (i == 0)
cout << "";
else
cout << "\nWRONG CHOICE!!!\nTRY AGAIN";
}
}
void student()
{
string id;
int flag = 0;;
cout << "Enter your Id ";
cin >> id;
for (int i = 0; i < 100; ++i) {
if (id == ListOfStudents[i].GetID())
flag = 1;
}
if (flag == 1) {
system("CLS");
cout << "\t\t\t-----------------------------------------\n";
cout << "\t\t\t University Management System\n";
cout << "\t\t\t-----------------------------------------\n";
cout << "\t\t\t Student Portal\n";
int i = -1;
while (i != 0)
{
cout << "\n\t\t\tEnter <1> Register Course"
<< "\n\t\t\tEnter <2> View Transcript"
<< "\n\t\t\tEnter <0> To Exit\n";
cout << "\n\n\t\t\tEnter Your Choice: ";
cin >> i;
if (i == 1) {
RegisterCourse(id);
}
if (i == 2) {
ViewTranscript(id);
}
}
}
else
cout << "Invalid ID" << endl;
}
void interface()
{
ifstream indata; // indata is like cin
string data;
indata.open("Courses.txt"); // opens the file
if (!indata) { // file couldn't be opened
cerr << "Error: file could not be opened" << endl;
exit(1);
}
indata >> data;
string cname, ccode;
while (!indata.eof()) { // keep reading until end-of-file
ListOfCourses[counter].SetCode(data);
indata >> data;
ListOfCourses[counter].Setname(data);
indata >> data;
counter++;
}
indata.close();
indata; // indata is like cin
data;
indata.open("Students.txt"); // opens the file
if (!indata) { // file couldn't be opened
cerr << "Error: file could not be opened" << endl;
exit(1);
}
indata >> data;
cname, ccode;
while (!indata.eof()) { // keep reading until end-of-file
ListOfStudents[counterStudent].SetId(data);
indata >> data;
ListOfStudents[counterStudent].SetName(data);
indata >> data;
counterStudent++;
}
indata.close();
indata; // indata is like cin
data;
indata.open("Registeration.txt"); // opens the file
if (!indata) { // file couldn't be opened
cerr << "Error: file could not be opened" << endl;
exit(1);
}
indata >> data;
cname, ccode;
while (!indata.eof()) { // keep reading until end-of-file
listOfReg[countreg].Setcourse(data);
indata >> data;
listOfReg[countreg].SetStudent(data);
indata >> data;
countreg++;
}
indata.close();
system("CLS");
int i = -1;
while (i != 0)
{
system("CLS");
cout << "\t\t\t-----------------------------------------\n";
cout << "\t\t\t University Management System\n";
cout << "\t\t\t-----------------------------------------\n";
cout << "\n\t\t\tLOGIN AS"
<< "\n\t\t\tEnter <1> Academic Officer"
<< "\n\t\t\tEnter <2> Teacher"
<< "\n\t\t\tEnter <3> Student"
<< "\n\t\t\tEnter <0> to Exit\n";
cout << "\n\n\t\t\tEnter Your Choice: ";
cin >> i;
switch (i)
{
case 1:
AcademicOfficer();
break;
case 2:
Teacher();
break;
case 3:
student();
break;
case 0:
break;
default:
i = -1;
cout << "\nWRONG CHOICE!!!\nTRY AGAIN";
}
}
}