Code:
#include<iostream>
#include<string>
using namespace std;
class employee
{
public:
int id;
string name;
void setdata(int id0,string name0)
{
id=id0;
name=name0;
}
int getid()
{
return id;
}
string getname()
{
return name;
}
};
class eperment : public employee
{
public:
int sal,allow;
void setsal(int sal0)
{
sal=sal0;
}
void setallow(int allow0)
{
allow=allow0;
}
int getsal()
{
return sal;
}
int getallow()
{
return allow;
}
friend istream& operator >>(istream& is,eperment &a)
{
cout<<"Enter the id: ";
is>>a.id;
cout<<"Enter the name: ";
is>>a.name;
cout<<"Enter the sal: ";
is>>a.sal;
cout<<"Enter the allowances: ";
is>>a.allow;
return is;
}
friend ostream& operator <<(ostream& os,eperment &a)
{
cout<<endl<<" The id: ";
os<<a.id;
cout<<endl<<"The name: ";
os<<a.name;
cout<<endl<<"The sal: ";
os<<a.sal;
cout<<endl<<"The allowances: "<<endl;
os<<a.allow;
cout<<"Net Basic sal";
os<<a.sal+a.allow;
cout<<endl;
return os;
}
};
class evisit : public employee
{
public:
int hours,rph;
void setdata(int hours0,int rph0)
{
hours=hours0;
rph=rph0;
}
int gethours()
{
return hours;
}
int getrph()
{
return rph;
}
friend istream& operator >>(istream& is,evisit &b)
{
cout<<"Enter the id: ";
is>>b.id;
cout<<"Enter the name: ";
is>>b.name;
cout<<"Enter the hours: ";
is>>b.hours;
cout<<"Enter the Rate per hour: ";
is>>b.rph;
return is;
}
friend ostream& operator <<(ostream& os,evisit &b)
{
cout<<endl<<" The id: ";
os<<b.id;
cout<<endl<<"The name: ";
os<<b.name;
cout<<endl<<"The hours: ";
os<<b.hours;
cout<<endl<<"The Rate per hour: ";
os<<b.rph;
cout<<endl<<"Net amount is";
os<<b.hours * b.rph;
cout<<endl;
return os;
}
};
int main()
{
eperment a[2];
evisit b[2];
int i;
cout<<"Enter the perment emp data"<<endl;
for(i=0;i<2;i++)
{
cin>>a[i];
}
cout<<"Enter the visiting emp data"<<endl;
for(i=0;i<2;i++)
{
cin>>b[i];
}
int loc=0;
int large =a[0].sal+a[0].allow;
for(i=0;i<2;i++)
{
if(large<a[i].sal+a[i].allow)
{
large=a[i].sal+a[i].allow;
loc=i;
}
}
;
int loc1=0;
int large1 =b[0].hours*b[0].rph ;
for(i=0;i<2;i++)
{
if(large1<b[i].hours*b[i].rph )
{
large1=b[i].hours*b[i].rph ;
loc1=i;
}
}
if(a[loc].sal+a[loc].allow>b[loc1].hours*b[loc1].rph)
{
cout<<"The perment emp is greater sal"<<endl;
cout<<a[loc];
}
else
{
cout<<"The visit emp is greater sal"<<endl;
cout<<b[loc1];
}
/*cout<<"the perment emp data"<<endl;
for(i=0;i<2;i++)
{
cout<<a[i];
}
cout<<"the visiting emp data"<<endl;
for(i=0;i<2;i++)
{
cout<<b[i];
}
*/
return 0;
}
//contact me by 03226133632