forked from tamycova/30DaysHR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
day12.cpp
74 lines (66 loc) · 1.09 KB
/
day12.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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
class Student{
protected:
string firstName;
string lastName;
int phone;
public:
Student(string fname, string lname, int p){
firstName = fname;
lastName = lname;
phone = p;
}
void display(){
cout << "First Name: " << firstName << "\nLast Name: " << lastName << "\nPhone: " << phone;
}
};
class Grade : public Student{
public:
~Grade(){};
Grade(string f, string s, int p, int sc) : Student(f, s, p) {
score = sc;
};
char calculate(){
if (score < 40)
{
return 'D';
}
else if (score < 60)
{
return 'B';
}
else if (score < 75)
{
return 'A';
}
else if (score < 90)
{
return 'E';
}
else
{
return 'O';
}
}
private:
int score;
};
int main() {
string firstName, lastName;
int score, phone;
cin >> firstName;
cin >> lastName;
cin >> phone;
cin >> score;
Student *stu = new Grade(firstName, lastName, phone, score);
stu->display();
Grade *g = (Grade*)stu;
cout << "\nGrade: " << g->calculate();
return 0;
}