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 {
private:
int emp_id;
char emp_name[32];
float basic_salary;
float allowance;
float PF;
public :
void getemployee();
// float find_net_salary(float basic_salary, float da, float PF);
void display();
};
void Employee :: getemployee()
{
cout << endl << "Enter employee id: ";
cin >> emp_id;
cout << "Enter employee name: ";
cin.ignore();
cin.getline(emp_name, 32);
cout << "Basic_salary: ";
cin >> basic_salary;
cout << "Allowance: ";
cin >> allowance;
cout << "PF: ";
cin >>PF;
}
void Employee::display() {
cout <<"===============================" << endl
<<"Employee ID "<< emp_id << endl
<<"Employee name " << emp_name <<endl
<<"Basic salary " << basic_salary << endl
<<"Allowance " << allowance << endl
<<"PF "<< PF << endl
<<"Net salary "<<basic_salary+allowance+PF << endl<<endl;
}
int main()
{
Employee Emp01;
Emp01.getemployee();
Emp01.display();
Employee Emp02;
Emp02.getemployee();
Emp02.display();
Employee Emp03;
Emp03.getemployee();
Emp03.display();
return 0;
}
Comments
Leave a comment