This program will calculate an employees pay based on gross
Solution
#include<iostream.h>
#include<conio.h>
#define SIZE 5
class emp
{
float basic,da,it,netsal;
char name[20],num[10];
public:
void getdata();
void net_sal();
void dispdata();
};
void emp::getdata()
{
cout<<\"\ Enter employee number: \" ;
cin>>name;
cout<<\" Enter employee name: \" ;
cin>>num;
cout<<\"Enter employee basic salary in Rs: \" ;
cin>>basic;
}
void emp::net_sal()
{
da=((0.52)*basic );
float gsal=da+basic;
it=((0.3)*gsal);
netsal=gsal-it;
}
void emp::dispdata()
{
cout
<<\"\ Employee number: \"<<name
<<\"\ Employee name: \"<<num
<<\"\ Employee netsalary: \"<<netsal<<\" Rs.\";
}
void main()
{
clrscr();
emp ob[SIZE];
int n;
cout<<\"\ \ ***********************************\"
<<\"\ Calculation of Employee Net Salary\"
<<\"\ ***********************************\"
<<\"\ Enter the number of employees\";
cin>>n;
for(int i=0;i<n;i++)
{
ob[i].getdata();
ob[i].net_sal();
}
clrscr();
cout<<\"\ -----------------\"
<<\"\ Employee Detail::\"
<<\"\ -----------------\";
for( i=0;i<n;i++)
{
cout<<\"\ \ Employee:\"<<i+1
<<\"\ ----------\";
ob[i].dispdata();
}
getch();
}

