Question: Write a simple payroll program that would: 1. Change the structure in project #3 to a class (adding a member variable called grossPay; 2. Making

Write a simple payroll program that would: 1. Change the structure in project #3 to a class (adding a member variable called grossPay; 2. Making all member variables of the class private; 3. Add constructors, mutators, accessors, input, & output functions; 4. Write a main function to: a. Read employees records from a disk file (attached with email for project #3) the array of class defined in step 1. The text file includes records of employees. Each record includes: employees name (30 bytes), employees id (5 bytes), hourly rate(int), hours worked (int). b. Calculate the gross pay for each employee based on the hourly rate and the hours worked and store this piece of information in the member variable called grossPayof the class. c. Display on the screen all employees name and gross pay as a report. d. Display the highest gross pay of the company. e. Display the average of gross pay of the company. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Project #3:

#include

#include

#include

using namespace std;

#define MAX 5

struct Employee{ //Employee Structure

char name[30];

char emp_id[5];

int hourly_rate;

int hours_worked;

double wage;

};

int main(){

Employee emp[MAX];

ifstream in; //Created object of the ifstream

in.open("Project 3.dat"); //Call object to open the file

if(in.fail()){

cout

return 0;

}

int n=0;

while(!in.eof()){ //Loop

in>>emp[n].name>>emp[n].emp_id>>emp[n].hourly_rate>>emp[n].hours_worked;

emp[n].wage = emp[n].hourly_rate * emp[n].hours_worked;

n++;

}

for(int i=0; i

for(int j=i+1; j

if(emp[i].wage >emp[j].wage){

Employee temp = emp[i];

emp[i] = emp[j];

emp[j] = temp;

}

}

}

double avg_wage = 0.0;

for(int i=0; i

cout

avg_wage += emp[i].wage;

}

avg_wage /= (double)n;

cout

return 0;

}

//Screenshot of Project #3 output.

Write a simple payroll program that would: 1. Change the structure in

l Edit Search w Project Execure Tool AStyle Wndow Hep Project Clasis Dibug min pp Pro ect Sumain using nawapacn std s.LOng G.Santos ASmith $758 9o $188e 51218 struct plplayee structurs Farkas Average wag:$012 15 char Process exited fter 0.044b seconds with return value Press any kay ta continue int hourly rat 19 int hours warked double nage ; -int main(){ 29 | fstrea" in; //treated cbject af trw ifstrva. in.upan&pruject s.dt f(in.fai1(D( call abject to open the fil 5 coutee Unable to open file ccedl; /error sg int n ; while(!n.uuf()){ n>>mp [n] .nww //Loup | )"r(n..enjd>>"r(n",huurly-rate> >"].huurs w rked ; 45 Shurtanlumipilurputha I- ontput T11ename; C ;\"serstuser\Deemop\DEV Prodec 3 aln.exe - Coopiiacion Time 0.395 Li: 87 Done par lype here to search

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!