0% found this document useful (0 votes)
10 views2 pages

Employee Salary Calculation System

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Employee Salary Calculation System

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include <iostream>

#include <string>

using namespace std;

class Employee {
protected:
int e_number;
string e_name;
string department;
float basic_salary;
char grade;
public:
void get_details() {
cout << "Enter employee number: ";
cin >> e_number;
cout << "Enter employee name: ";
[Link]();
getline(cin, e_name);
cout << "Enter department name: ";
getline(cin, department);
cout << "Enter basic salary: ";
cin >> basic_salary;
cout << "Enter grade: ";
cin >> grade;
}
void display_details() {
cout << "Employee number: " << e_number << endl;
cout << "Employee name: " << e_name << endl;
cout << "Department: " << department << endl;
cout << "Basic salary: " << basic_salary << endl;
cout << "Grade: " << grade << endl;
}
};

class Pay : public Employee {


private:
float da;
float hra;
float pf;
public:
void calculate_da() {
switch(grade) {
case 'A':
da = basic_salary * 0.8;
break;
case 'B':
da = basic_salary * 0.6;
break;
case 'C':
da = basic_salary * 0.4;
break;
default:
da = 0;
break;
}
}
void calculate_hra_pf() {
switch(grade) {
case 'A':
hra = basic_salary * 0.2;
pf = basic_salary * 0.1;
break;
case 'B':
hra = basic_salary * 0.15;
pf = basic_salary * 0.08;
break;
case 'C':
hra = basic_salary * 0.1;
pf = basic_salary * 0.05;
break;
default:
hra = 0;
pf = 0;
break;
}
}
void display_pay() {
cout << "DA: " << da << endl;
cout << "HRA: " << hra << endl;
cout << "PF: " << pf << endl;
}
};

int main() {
Pay p;
p.get_details();
p.display_details();
p.calculate_da();
p.display_pay();
p.calculate_hra_pf();
p.display_pay();
return 0;
}

You might also like