-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrading system.cpp
More file actions
98 lines (68 loc) · 1.77 KB
/
grading system.cpp
File metadata and controls
98 lines (68 loc) · 1.77 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
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int indexmax;
struct studentType {
int index;
string studentFName;
string studentLName;
int testScore;
char grade;
};
void readData (studentType array [20]);
void grade (studentType array [20]);
void highestScore (studentType array [20]);
void print (studentType array [20]);
int main() {
studentType array [20];
ifstream infile("StudentsData.txt");
infile.open("StudentsData.txt");
readData(array);
return 0;
}
void readData (studentType array [20]){
ifstream infile;
if (infile.is_open())
{
while(! infile.eof()){
for (int i = 0; i < 20; i++){
infile >> array[i].index;
infile >> array[i].studentFName;
infile >> array[i].studentLName;
infile >> array[i].testScore;
infile >> array[i].grade;
}
}
}
cout<<array[0].index<<" "<<array[0].studentFName<<" "<<array[0].studentLName<<" "<<array[0].testScore<<" "<<array[0].grade;
}
void grade (studentType array [20]){
for (int i = 0; i < 20; i++){
if (array[i].testScore >= 80){
array[i].grade = 'A';
}
else if (array[i].testScore >= 70){
array[i].grade = 'B';
}
else if (array[i].testScore >= 60){
array[i].grade = 'C';
}
else if (array[i].testScore >= 50){
array[i].grade = 'D';
}
else if (array[i].testScore <= 40){
array[i].grade = 'F';
}
}
}
void highestScore (studentType array [20]){
indexmax = 0;
for (int i = 1; i < 20; i++){
if (array[i].testScore >= array[indexmax].testScore){
indexmax = i;
}
}
}
void print (studentType array [20]){
}