-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee Payroll System.cpp
More file actions
56 lines (46 loc) · 1.47 KB
/
Employee Payroll System.cpp
File metadata and controls
56 lines (46 loc) · 1.47 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
#include <iostream>
#include <cstring>
using namespace std;
// Creating a class Employee and a derived class PartTimeEmployee to demonstrate the scenario
class Employee {
private:
char name[40];
char address[40];
int age;
protected:
Employee(char employeeName[], char employeeAddress[], int employeeAge) {
strcpy(name, employeeName);
strcpy(address, employeeAddress);
age = employeeAge;
}
void printDetails() {
cout << "\nName: " << name
<< "\nAddress: " << address
<< "\nAge: " << age;
}
};
class PartTimeEmployee : protected Employee {
private:
int numberOfDaysWorked;
long paymentPerDay;
long totalPay;
public:
PartTimeEmployee(char employeeName[], char employeeAddress[],
int employeeAge, int daysWorked, long payment) : Employee(employeeName,
employeeAddress, employeeAge) {
numberOfDaysWorked = daysWorked;
paymentPerDay = payment;
totalPay = numberOfDaysWorked * paymentPerDay;
}
void displayDetails() {
printDetails();
cout << "\nNumber of days worked: " << numberOfDaysWorked
<< "\nPayment per day: " << paymentPerDay
<< "\nTotal pay: " << totalPay;
}
};
int main() {
PartTimeEmployee employee("Sayan Banik", "Cooch Behar, West Bengal, India", 19, 12, 1000);
employee.displayDetails();
return 0;
}