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; }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 2CP
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage