In: Electrical Engineering
write a programme named question5a.cpp that calculate and print pay slip
Program code:
#include<iostream>
using namespace std;
class Emp
{
int id;
char name[100];
float basicsalary, hra, da, tax, net_salary;
public:
void accept()
{
cout<<"\n Enter Employee Id : ";
cin>>id;
cout<<"\n Enter Employee Name : ";
cin>>name;
cout<<"\n Enter Basic Salary : ";
cin>>basicsalary;
hra = 1000;
da = 0.25 * basicsalary;
tax = 0.15 * basicsalary;
net_salary = basicsalary + da + hra - tax;
}
void disp()
{
cout<<"\n ----------------------- ";
cout<<"\n Employee Id : "<<id;
cout<<"\n Employee Name : "<<name;
cout<<"\n Basic Salary : "<<basicsalary;
cout<<"\n HRA : "<<hra;
cout<<"\n DA : "<<da;
cout<<"\n I-Tax : "<<tax;
cout<<"\n Net Salary : "<<net_salary;
}
};
int main()
{
Emp e;
e.accept();
e.disp();
return 0;
}