question:
Expand the Employee Payroll program to include hourly based and salary based
employees. This phase uses an array of employee objects, inheritance for different classes of employees, and polymorphism for salary computation. The 52 week yearly salary as well as number of overtime hours worked by a salary based employee is given). For salary based employees, to find the regular (gross) pay for a week, divide the salary by 52. To compute the overtime pay for a salary based employee, first find the hourly rate by dividing
the gross pay by 40, and then compute overtime pay. For every employee,
overtime pay, tax amount, and net pay must also be computed. In addition, the program should find the minimum and maximum net pay of all employees as well as sort the employees based on their net pay (ascending order)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
#include<stdio.h>
#include<iostream>
#include<conio.h>
using namespace std;
const int t=8;
class emp
{
public:
char name[20];
float npay;
float tax;
float opay;
int etype;
void eaccept()
{
cout<<"enter employee name : ";
cin>>name;
}
void edisp()
{
cout<<"employee name : "<<name;
}
friend class minmax;
};
class hour : public emp
{
public:
int hpay;
int hno;
int ho;
void haccept()
{
cout<<"enter hourly rate, and number of hours worked and number of hours overtime\n";
cin>>hpay;
cin>>hno;
cin>>ho;
etype=1;
}
void pay1()
{
opay=(ho*hpay);
tax=(hpay*(hno+ho))*t/100;
npay=(hpay*(hno+ho))-tax;
}
void hdisp()
{
cout<<"hourly nased employee";
cout<<"\novertime pay : "<<opay;
cout<<"\ntax amount : "<<tax;
cout<<"\nnet pay : "<<npay;
}
};
class sal : public emp
{
public:
int slry;
int no;
int hrate;
void saccept()
{
cout<<"enter yearly salary and number of overtime hours worked";
cin>>slry;
cin>>no;
etype=2;
}
void pay2()
{
hrate=slry/52/40;
opay=hrate*no;
tax=(slry+opay)*t/100;
npay=slry+opay-tax;
}
void sdisp()
{
cout<<"salary based employee";
cout<<"annual salary :"<<slry;
cout<<"hourly rate :"<<(slry/52/40);
cout<<"\novertime pay : "<<opay;
cout<<"\ntax amount : "<<tax;
cout<<"\nnet pay : "<<npay;
}
};
class minmax : virtual hour, virtual sal
{
};
int main()
{
minmax min[10];
int ctr=0;
int m1=0,m2=0;
int ch;
do
{
cout<<"\n1.add hourly employee \n2.add salary employee \n3. find min and max pay \n4.sort in ascending order \n5.exit";
cin>>ch;
switch(ch)
{
case 1:
if(ctr<10)
{
ctr++;
min[ctr].eaccept();
min[ctr].haccept();
min[ctr].pay1();
min[ctr].edisp();
min[ctr].hdisp();
}
break;
case 2:
if(ctr<10)
{
ctr++;
min[ctr].eaccept();
min[ctr].saccept();
min[ctr].pay2();
min[ctr].edisp();
min[ctr].sdisp();
}
break;
case 3:
for(int i=1;i<=ctr;i++)
{
if(min[i].npay<min[m1].npay)
{
m1=i;
}
if(min[i].npay>min[m2].npay)
{
m2=i;
}
}
cout<<"details of minimum pay employee :"
if(min[m1].etype==1)
{
min[m1].edisp();
min[m1].hdisp();
}
if(min[m1].etype==2)
{
min[m1].edisp();
min[m1].sdisp();
}
cout<<"details of maxmum pay employee :"
if(min[m2].etype==1)
{
min[m2].edisp();
min[m2].hdisp();
}
if(min[m2].etype==2)
{
min[m2].edisp();
min[m2].sdisp();
}
break;
case 4:
for(int i=0;i<=ctr;i++)
{
if(min[i].npay<min[m1].npay)
{
m1=i;
}
if(min[i].npay>min[m2].npay)
{
m2=i;
}
}
cout<<"the employees in sorted order are: ";
for(int j=0;j<=ctr;j++)
{
if(min[j].etype==1)
{
min[j].edisp();
min[j].hdisp();
}
if(min[j].etype==2)
{
min[j].edisp();
min[j].sdisp();
}
}//end for
break;
exit(0);
}
}while(ch!=5);
getch();
system("pause");
}
|
the type of errors im getting are :
request for member eaccept() is ambiguous
hour::haccept() is inaccessible
etc
please help me out!