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 <iostream> #include <iomanip> 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 << " employees:\n";      for (count = 0; count < NUM_EMPLOYEES; count++)    {      // 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 pay:\n";    cout << setprecision(2) << fixed << showpoint << right;    for ( count = 0; count < NUM_EMPLOYEES; count++)    {      cout << "\tEmployee #" << (count+1) << ": ";      cout << setw(8) << employees[count].getTotalPay() << endl;      }      return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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 <iostream>

#include <iomanip>

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 << " employees:\n";

 

   for (count = 0; count < NUM_EMPLOYEES; count++)

   {

     // 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 pay:\n";

   cout << setprecision(2) << fixed << showpoint << right;

   for ( count = 0; count < NUM_EMPLOYEES; count++)

   {

     cout << "\tEmployee #" << (count+1) << ": ";

     cout << setw(8) << employees[count].getTotalPay() << endl;

 

   }

 

   return 0;

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education