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).
I am getting [Error] invalid conversion from 'char*' to 'char' [-fpermissive]
#include #include #include #include using namespace std; class payroll{ ifstream fin; int n; public: char fname, lname; char paystat, maritalstatus, employeeid; float taxrate; double hoursworked, overtimehours, regularhours, othr; double reghourlyrate,regularpay,totalnetpay,minnp,maxnp; double avgnetpay,taxamount,netpay,grosspay,overtimepay; virtual double findgrosspay(); void setvariables(char, char, char, char, char, double, double); virtual double findtaxamount(); virtual double findnetpay(); virtual double findavgnetpay(); void printheadings(); void printdata(); double minnet(double, int); double maxnet(double, int); void printminmax(double, double); void printreport(); void sortbypointers(void); payroll(); ~payroll(); }; class hourly: public payroll{ public: double findgrosspay(){ if(hoursworked>40){ overtimehours=hoursworked-40; othr=reghourlyrate*1.5; regularpay=hoursworked*reghourlyrate; overtimepay=overtimehours*(reghourlyrate*1.5); grosspay=regularpay+overtimepay; } else{ grosspay=hoursworked*reghourlyrate; regularpay=grosspay; overtimehours=0; overtimepay=0; return grosspay; }//IF };//findgrosspay }; class salaried: public payroll{ public: double findgrosspay(){ if(hoursworked>0){ overtimepay=hoursworked*(regularpay/52/40); regularpay=reghourlyrate/52; grosspay=regularpay+overtimepay; return grosspay; }//If };//findgrosspay }; payroll::payroll(){ fin.open("salariedemployees.txt"); } payroll::~payroll() { fin.close();} double payroll::findtaxamount() { taxrate=.30; taxamount=grosspay*taxrate; return taxamount; }//findtaxamount double payroll::findgrosspay() { if(hoursworked>0) { overtimepay=hoursworked*(regularpay/52/40); regularpay=reghourlyrate/52; grosspay=regularpay+overtimepay; return grosspay; }//If }//findgrosspay double payroll::findnetpay() { netpay=grosspay-taxamount; totalnetpay=totalnetpay+netpay; return netpay; }//findnetpay double payroll::findavgnetpay() { avgnetpay=totalnetpay/n; cout<maxnp) {maxnp=netpay;} cout<p[j+1]) { temp=p[j]; p[j]=p[j+1]; p[j+1]=temp; sortedflag=0; }//SWAP }//J }//I cout< fname = afname; lname = alname; maritalstatus = amaritalstatus; employeeid = aemployeeid; paystat = apaystat; hoursworked = ahoursworked; reghourlyrate = areghourlyrate; }// setvariables void payroll::printheadings(){ cout< void payroll::printreport() { n=0,totalnetpay=0; printheadings(); while(fin>>fname>>lname>>paystat>>maritalstatus>>employeeid>>hoursworked>>reghourlyrate) { findgrosspay(); findtaxamount(); findnetpay(); printdata(); sortbypointers(); n++; }//WHILE avgnetpay=findavgnetpay(); cout<<"The average net pay for "<printreport(); int i=0; char afname[14], alname[16], apaystat, amaritalstatus, aemployeeid; double ahoursworked, areghourlyrate, minnp,maxnp, netpays[8]; void sortnetpays(double netpays[], int i); report->printheadings(); ifstream fin; fin.open("salariedemployees.txt"); while(fin>>afname>>alname>>apaystat>>amaritalstatus>>aemployeeid>>ahoursworked>>areghourlyrate) { if(apaystat=='s') { employee[i]=new salaried(); employee[i]->setvariables(afname, alname, apaystat, amaritalstatus, aemployeeid, ahoursworked, areghourlyrate); employee[i]->findgrosspay(); }//if s if(apaystat=='h') { employee[i]=new hourly(); employee[i]->setvariables(afname, alname, apaystat, amaritalstatus, aemployeeid, ahoursworked, areghourlyrate); employee[i]->findgrosspay(); }//if h employee[i]->findtaxamount(); netpays[i]=employee[i]->findnetpay(); minnp = employee[i]->minnet(minnp, i); maxnp = employee[i]->maxnet(maxnp, i); employee[i]->printdata(); i++; }//WHILE fin.close(); system ("pause"); }//MAIN