-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay +12.cpp
29 lines (24 loc) · 836 Bytes
/
Day +12.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
//Inheritance
//program to complete student class when person class is given
class Student : public Person {
private:
vector<int> testScores;
public:
// Write your constructor
Student(string firstName, string lastName, int id, vector<int> scores) : Person(firstName, lastName, id) {
this->testScores = scores;
}
// Write char calculate()
char calculate() {
int total = 0;
for (int i = 0; i < this->testScores.size(); i++)
total += this->testScores[i];
int avg = (int) (total / testScores.size());
if (avg >= 90 && avg <= 100) return 'O';
if (avg >= 80 && avg < 90) return 'E';
if (avg >= 70 && avg < 80) return 'A';
if (avg >= 55 && avg < 70) return 'P';
if (avg >= 40 && avg < 55) return 'D';
return 'T';
}
};