The class employee comprises of employee details such as emp_id(integer type), employee name(character array type) ,basic salary(float type), allowance(float type) and PF(float type). Get three employee details using getemployee() method and use display() method to calculate and display the net salary(basic salary+allowance+PF) of employees.
Note:Use the concept of class and objects.
#include <iostream>
using namespace std;
class employee
{
int emp_id;
char emp_name[20];
float emp_basic_salary;
float emp_da;
float emp_PF;
float emp_net_sal;
public:
void get_emp_details();
float find_net_salary(float basic_salary, float da, float PF);
void display_emp_details();
};
void employee :: get_emp_details()
{
cout<<"\nEnter employee id: ";
cin>>emp_id;
cout<<"\nEnter employee name: ";
cin>>emp_name;
cout<<"\nEnter employee basic_salary: ";
cin>>emp_basic_salary;
cout<<"\nEnter employee DA: ";
cin>>emp_da;
cout<<"\nEnter employee PF: ";
cin>>emp_PF;
}
float employee :: find_net_salary(float basic_salary, float da, float PF)
{
return (basic_salary+da)-PF;
}
void employee :: display_emp_details()
{
cout<<"\n\n**** Details of Employee ****";
cout<<"\nEmployee Name : "<<emp_name;
cout<<"\nEmployee number : "<<emp_id;
cout<<"\nBasic salary : "<<emp_basic_salary;
cout<<"\nEmployee DA : "<<emp_da;
cout<<"\nIncome Tax : "<<emp_PF;
cout<<"\nNet Salary : "<<find_net_salary(emp_basic_salary, emp_da, emp_PF);
cout<<"\n-------------------------------\n\n";
}
int main()
{
employee emp;
emp.get_emp_details();
emp.display_emp_details();
return 0;
}
Comments
Leave a comment