ohmy.codes

IP 160.86.0.0 Created 01-01 00:54
1
using namespace std;
2
#include <iostream>
3
4
int main() {
5
int score, maxScore = 0, minScore = 100;
6
int a = 0, b = 0, c = 0, d = 0, f = 0;
7
int studentCount = 0;
8
9
cout << "Enter grades(-1 to quit)" << endl;
10
cin >> score;
11
12
while (score != -1) {
13
studentCount++;
14
switch (score/10) {
15
case 10:
16
case 9: a++; break;
17
case 8: b++; break;
18
case 7: c++; break;
19
case 6: d++; break;
20
default: f++; break;
21
}
22
if (score > maxScore) maxScore = score;
23
if (score < minScore) minScore = score;
24
25
cin >> score;
26
}
27
28
cout << "* Total number of students = " << studentCount << endl;
29
cout << "* Number of A = " << a << endl;
30
cout << "* Number of B = " << b << endl;
31
cout << "* Number of C = " << c << endl;
32
cout << "* Number of D = " << d << endl;
33
cout << "* Number of F = " << f << endl;
34
35
if (studentCount == 0) {
36
cout << "* The highest score: " << endl;
37
cout << "* The lowest score: " << endl;
38
} else {
39
cout << "* The highest score: " << maxScore << endl;
40
cout << "* The lowest score: " << minScore << endl;
41
}
42
43
return 0;
44
}