Coding hub - 1
#include <iostream>
using namespace std;
class emp
{
public:
int eno;
char name[20],des[20];
void get()
{
cout<<"\n Enter the name of the employee: ";
cin>>name;
cout<<"\n Enter the designation: ";
cin>>des;
cout<<"\n Enter the emp number: ";
cin>>eno;
}
};
class salary:public emp
{
float bp,hra,da,pf,np;
public:
void get2()
{
cout<<"\n Enter the basic pay of the employee";
cin>>bp;
cout<<"\n Enter the House rent allowance: ";
cin>>hra;
cout<<"\n Enter the dearness allowance: ";
cin>>da;
cout<<"\n Enter the provident fund: ";
cin>>pf;
}
void calculate()
{
np=bp+hra+da-pf;
}
void display()
{
cout<<eno<<"\t"<<name<<"\t"<<des<<"\t"<<bp<<"\t"<<hra<<"\t"<<da<<"\t"<<pf<<"\t"<<np<<endl;
}
};
int main()
{
int i,n;
char ch;
salary s[10];
cout<<"\n Enter the number of the employee: ";
cin>>n;
for(i=0;i<n;i++)
{
s[i].get();
s[i].get2();
s[i].calculate();
}
cout<<"\n\t\t employee details \n";
cout<<" \n e_no \t e_name \t des \t hra \t da \t pf \t np"<<endl;
for (i=0;i<n;i++)
{
s[i].display();
}
return 0;
}
This coding is helpful to print out the name ,designation,basic pay,house rent allowance,dearness allowance,provident fund,normal price.
Try once by yourself.
using namespace std;
class emp
{
public:
int eno;
char name[20],des[20];
void get()
{
cout<<"\n Enter the name of the employee: ";
cin>>name;
cout<<"\n Enter the designation: ";
cin>>des;
cout<<"\n Enter the emp number: ";
cin>>eno;
}
};
class salary:public emp
{
float bp,hra,da,pf,np;
public:
void get2()
{
cout<<"\n Enter the basic pay of the employee";
cin>>bp;
cout<<"\n Enter the House rent allowance: ";
cin>>hra;
cout<<"\n Enter the dearness allowance: ";
cin>>da;
cout<<"\n Enter the provident fund: ";
cin>>pf;
}
void calculate()
{
np=bp+hra+da-pf;
}
void display()
{
cout<<eno<<"\t"<<name<<"\t"<<des<<"\t"<<bp<<"\t"<<hra<<"\t"<<da<<"\t"<<pf<<"\t"<<np<<endl;
}
};
int main()
{
int i,n;
char ch;
salary s[10];
cout<<"\n Enter the number of the employee: ";
cin>>n;
for(i=0;i<n;i++)
{
s[i].get();
s[i].get2();
s[i].calculate();
}
cout<<"\n\t\t employee details \n";
cout<<" \n e_no \t e_name \t des \t hra \t da \t pf \t np"<<endl;
for (i=0;i<n;i++)
{
s[i].display();
}
return 0;
}
This coding is helpful to print out the name ,designation,basic pay,house rent allowance,dearness allowance,provident fund,normal price.
Try once by yourself.
Comments
Post a Comment