-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwork13.cpp
More file actions
77 lines (69 loc) · 1.5 KB
/
Copy pathwork13.cpp
File metadata and controls
77 lines (69 loc) · 1.5 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
#include <iostream>
#include <string>
using namespace std;
class Score
{
private:
string name;
double s[4];
double total;
char grade;
public:
Score()
{
total = 0;
grade = 'B';
}
void Input()
{
cin >> name;
for (int i = 0; i < 4; i++)
{
cin >> s[i];
}
}
void Evalauate()
{
for (int i = 0; i < 2; i++)
{
if (s[i] < 0 || s[i] > 50)
{
cout << "error" << endl;
exit(0);
}
}
for (int i = 2; i < 4; i++)
{
if (s[i] < 0 || s[i] > 100)
{
cout << "error" << endl;
exit(0);
}
}
double attendance1 = (s[0] / 50.0) * 100;
double attendance2 = (s[1] / 50.0) * 100;
total = attendance1 * 0.125 + attendance2 * 0.125 + s[2] * 0.25 + s[3] * 0.5;
if (total >= 90 && total <= 100)
grade = 'A';
else if (total >= 80 && total <= 89)
grade = 'B';
else if (total >= 70 && total <= 79)
grade = 'C';
else if (total >= 60 && total <= 69)
grade = 'D';
else if (total >= 0 && total < 60)
grade = 'E';
}
void Output()
{
cout << "name: " << name << ", total: " << total << ", grade: " << grade << endl;
}
};
int main()
{
Score *s1 = new Score;
s1->Input();
s1->Evalauate();
s1->Output();
return 0;
}