forked from thakurRashmi/Begineer_Friendly_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVirtual_function.cpp
More file actions
152 lines (136 loc) · 3.29 KB
/
Virtual_function.cpp
File metadata and controls
152 lines (136 loc) · 3.29 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include <iostream>
using namespace std;
class Employee
{
string EmployeeName;
int id;
public:
Employee(string n, int id);
string getname();
virtual int raiseSalary() = 0;
};
Employee::Employee(string n, int id)
{
EmployeeName = n;
this->id = id;
}
string Employee::getname()
{
return EmployeeName;
}
//****************************************************************
class Engineer : public Employee
{
private:
int Salary1;
int Percentage;
public:
Engineer(string n, int id, int Percentage, int Salary1) : Employee(n, id)
{
this->Salary1 = Salary1;
this->Percentage = Percentage;
}
int getsalary()
{
return Salary1;
}
int raiseSalary()
{
return ((Salary1 * Percentage) / 100);
}
};
//****************************************************************
class TeamLeader : public Employee
{
private:
int Salary2;
int Percentage;
public:
TeamLeader(string n, int id, int Salary2, int Percentage) : Employee(n, id)
{
this->Salary2 = Salary2;
this->Percentage = Percentage;
}
int getsalary()
{
return Salary2;
}
int raiseSalary()
{
return ((Salary2 * Percentage) / 100);
}
};
//****************************************************************
class Manager : public Employee
{
private:
int Salary3;
int Percentage;
public:
Manager(string name, int id, int Salary3, int Percentage) : Employee(name, id)
{
this->Salary3 = Salary3;
this->Percentage = Percentage;
}
int getsalary()
{
return Salary3;
}
int raiseSalary()
{
return ((Salary3 * Percentage) / 100);
}
};
//****************************************************************
int main()
{
cout << "Welcome to Salary Increase Portal :" << endl;
cout << endl;
Employee *e[3];
string name;
int Id, choice, Per, salary;
cout << "Enter your Name : ";
cin >> name;
cout << "Enter your Id : ";
cin >> Id;
cout << "Emter your Salary : ";
cin >> salary;
cout << endl;
while (1)
{
cout << "1] Engineer " << endl
<< "2] TeamLeader" << endl
<< "3] Manager" << endl;
cout << "Enter your chocice : ";
cin >> choice;
cout << endl;
switch (choice)
{
case 1:
cout << "Enter Percentge for Engineer Salary Raise :";
cin >> Per;
e[0] = new Engineer(name, Id, salary, Per);
cout << "Rise in salary is : " << e[0]->raiseSalary() << endl;
cout << endl;
break;
case 2:
cout << "Enter Percentge for Manager Salary Raise :";
cin >> Per;
e[1] = new Manager(name, Id, salary, Per);
cout << "Rise in salary is : " << e[1]->raiseSalary() << endl;
cout << endl;
break;
case 3:
cout << "Enter Percentge for TeamLeader Salary Raise :";
cin >> Per;
e[2] = new TeamLeader(name, Id, salary, Per);
cout << "Rise in salary is : " << e[2]->raiseSalary() << endl;
cout << endl;
break;
default:
cout << "Enter a Valid choice !!!!!!" << endl;
break;
}
}
return 0;
}