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.
#include <iostream>
using namespace std;
class employee
{
private:
//emp_id(integer type), employee name(character array type)
int id;
char name[15];
//basic salary(float type), allowance(float type) and PF(float type).
float basic_salary;
float allowance;
float PF;
public:
//Get three employee details using getemployee() method
void getemployee(){
cout<<"Enter employee id: ";
cin>>id;
cout<<"Enter employee name: ";
cin>>name;
cout<<"Enter employee basic salary: ";
cin>>basic_salary;
cout<<"Enter employee allowance: ";
cin>>allowance;
cout<<"Enter employee PF: ";
cin>>PF;
}
void display(){
//calculate and display the net salary(basic salary+allowance+PF) of employees.
float net_salary=basic_salary+allowance+PF;
cout<<"\nThe net salary: "<< net_salary<<"\n";
}
};
int main(){
employee empl;
empl.getemployee();
empl.display();
system("pause");
return 0;
}
Comments
Leave a comment