-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
114 lines (93 loc) · 3.39 KB
/
main.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
#include <iostream>
#include "LinkedList.h"
#include "Student.h"
#include "Utilities.h"
#include "Messages.h"
using namespace std;
int main() {
LinkedList<Student> studentList;
printWelcomeMessage();
int choice;
bool continueExecuting = true;
programStartQuit(continueExecuting);
// Read student data from file
readFileAndStoreData(studentList, "studentData.txt");
while (continueExecuting)
{
displayMenu();
choice = ValidateUpdateMarks<int>(1, 6);
switch (choice) {
case 1:
studentList.printAll();
break;
case 2: {
string id;
double coursework, finalExam;
cout << "Enter student ID to update: ";
cin >> id;
while(cin.fail())
{
cin.clear();
string dummy;
cin >> dummy;
cout << "ERROR! Invalid Input Detected." << endl;
cout << "Please enter letter \"S\" in uppercase followed by numbers only." << endl;
cin >> id;
}
Student* student = studentList.findById(id);
if (student)
{
updateMarkMenu();
int updateChoice;
updateChoice = ValidateUpdateMarks<int>(1, 3);
switch(updateChoice){
case 1:
cout << "Enter new coursework marks (0 - 50): ";
coursework = ValidateUpdateMarks<double>(0.0, 50.0);
break;
case 2:
cout << "Enter new final exam marks (0 - 50): ";
finalExam = ValidateUpdateMarks<double>(0.0, 50.0);
break;
case 3:
cout << "Enter new coursework marks (0 - 50): ";
coursework = ValidateUpdateMarks<double>(0.0, 50.0);
cout << "Enter new final exam marks (0 - 50): ";
finalExam = ValidateUpdateMarks<double>(0.0, 50.0);
break;
}
student->updateMarks(coursework, finalExam);
cout << "Marks updated!\n"; }
else
{
cout << "Student not found.\n";
}
}
case 3: {
Student* topStudent = getHighestScorer(studentList);
if (topStudent) {
cout << "Highest Scorer:\n";
topStudent->print();
} else {
cout << "No students found.\n";
}
break;
}
case 4: {
double average = calculateAverageMarks(studentList);
cout << "Average Marks: " << average << endl;
break;
}
case 5: {
double average = calculateAverageMarks(studentList);
cout << "Average Marks: " << average << endl;
break;
}
case 6: {
cout << "Exiting program.\n";
endProgram(continueExecuting);
}
}
}
return 0;
}