#include<iostream>
using namespace std;
class emp
{
public:
int eno;
char name [20],des[20];
void get()
{
cout<<"Enter employee no:";
cin>>eno;
cout<<"Enter employee name:";
cin>>name;
cout<<"Enter the designation:";
cin>>des;
}
};
class salary:public emp
{
float bp,hra,da,pf,np;
public:
void input()
{
cout<<"Enter Basic pay:";
cin>>bp;
cout<<"Enter HRA:";
cin>>hra;
cout<<"Enter DA:";
cin>>da;
cout<<"Enter PF:";
cin>>pf;
}
void calculate()
{
np=bp+hra+da-pf;
}
void display()
{
cout<<"Employee no:"<<eno;
cout<<"\n name:"<<name;
cout<<"\n designation:"<<des;
cout<<"\n net pay:"<<np;
}
};
int main()
{
int n,i;
salary s[3];
cout<<"Enter number of employees:";
cin>>n;
for(i=0;i<n;i++)
{
s[i].get();
s[i].input();
s[i].calculate();
}
for(i=0;i<n;i++)
{
s[i].display();
}
return 0;
}
OUTPUT:
BY
REGU RAM SV.
إرسال تعليق