-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employee_Sal.cpp
40 lines (34 loc) · 897 Bytes
/
Employee_Sal.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
//C++ program to get the salary and work hours of the employee and print the final salary
#include <iostream>
using namespace std;
class Employee {
public:
int sal,hours;
//Function to get the salary and work hours
void getInfo(){
cout<<"Enter the salary of the employee (in dollars): ";
cin>>sal;
cout<<"Enter the number of hours of work per day of the employere: ";
cin>>hours;
}
//Function to modify salary based on the salary amount
void AddSal(){
if (sal<500){
sal+=10;
}
}
//Function to modify salary based on the work hours
void AddWork(){
if (hours>6){
sal+=5;
}
}
};
int main() {
Employee Emp1;
Emp1.getInfo();
Emp1.AddSal();
Emp1.AddWork();
cout<<"The final salary of the employee is "<<Emp1.sal;
return 0;
}