#include<iostream.h>
#include<conio.h>
class employee
{
private:
int id;
float sal,netsal;
char name[20],des[20];
public:
void getdata();
void calculate();
void show();
};
void employee::getdata()
{
cout<<"\nEnter the employee name:";
cin>>name;
cout<<"\nEnter the employee id:";
cin>>id;
cout<<"\nEnter the employee designation:";
cin>>des;
cout<<"\nEnter the basic salary:";
cin>>sal;
}
void employee::calculate()
{
float da,pf,hra,tax,oth,gro,less;
if(sal>10000)
{
da=0.8*sal;
hra=0.5*sal;
pf=0.6*sal;
oth=0.2*sal;
less=pf+tax;
gro=sal+hra+da+oth;
netsal=gro-less;
}
else
{
da=0.6*sal;
hra=0.3*sal;
pf=0.5*sal;
oth=0.2*sal;
less=pf+tax;
gro=sal+hra+da+oth;
netsal=gro-less;
}
}
void employee::show()
{
cout<<"\nNAME\t:"<<name;
cout<<"\nID\t:"<<id;
cout<<"\nDESIGNATION:"<<des;
cout<<"\nNET SALARY:"<<netsal;
}
void main()
{
clrscr();
employee emp;
emp.getdata();
emp.calculate();
emp.show();
getch();
}
No comments:
Post a Comment