There is a PayRoll Class that has data members for an employee’s hourly pay rate, number of hours worked,and total pay for the week, There is also a program with an array of four PayRoll objects; this...


There is a PayRoll Class that has data members for an employee’s hourly pay rate, number of hours worked,and total pay for the week, There is also a program with an array of four PayRoll objects; this program asks the user to input the working hours and hourly pay rate for each employee and display the amount of gross pay each has earned.



Please revise this PayRoll Class and program as following:



  • The PayRoll Class also has a member variable named
    ID
    whose datatype is integer. We use
    ID
    to hold employee’s ID. The program also asks the user to input the employee’s ID for each employee in the array.

  • The program displays the highest amount of gross pay among the four employees and displays the employee’s ID who has this highest amount of gross pay.

  • The program displays the average values of gross pays among the four employees and displays the number of employees whose gross pay are above this average value.



Here is the original class and program


#include


#include


using namespace std;



class Payroll


{


private:


       double hours;


       double payRate;



public:


       // Constructor


       Payroll()


          { hours = 0; payRate = 0; }



       // Mutators


       void setHours(double h)


       {


             hours=h;


       }



       void setPayRate(double r)


             { payRate = r; }



       // Accessors


       double getHours() const


             { return hours; }



       double getPayrate() const


             { return payRate; }



       double getTotalPay() const


             { return hours * payRate; }


};


// Constant for number of employees


const int NUM_EMPLOYEES = 4;



int main()


{


   double hours;   // Hours worked


   double rate;   // Hourly pay rate


   int count;     // Loop counter



   // Array of Payroll objects


   Payroll employees[NUM_EMPLOYEES];



   // Get the hours worked and the pay rate


   // for each employee.


   cout < "enter="" the="" hours="" worked="" and="" pay="" rate="">


< "for="" "="">< num_employees="">< "="">



   for (count = 0; count < num_employees;="">


   {


     // Get the employee's pay rate.


     cout < "\nemployee="" #"="">< (count+1)="">< "="" pay="" rate:="">


     cin >> rate;


     employees[count].setPayRate(rate);



     // Get the employee's hours worked


     cout < "employee="" #"="">< (count+1)="">< "="" hours="" worked:="">


     cin >> hours;


     employees[count].setHours(hours);


   }



   // Display the total pay for each employee.


   cout < "total="">


   cout < setprecision(2)="">< fixed="">< showpoint=""><>


   for ( count = 0; count < num_employees;="">


   {


     cout < "\temployee="" #"="">< (count+1)="">< ":="">


     cout < setw(8)="">< employees[count].gettotalpay()=""><>



   }



   return 0;


}

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here