Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please provide an answer to the payroll question above the answer that was provi

ID: 3873681 • Letter: P

Question

Please provide an answer to the payroll question above the answer that was provided did not compiled.

please provide step-by-step solutions to chapter 13 program challenge 11 Payroll
please ensure that the step by step solution come from starting out with C ++ edition 8 up to chapter 14.

Design a payroll class that has a data member for an employee hourly pay rate, number of worked, and the total pay for the week. Write a program with an array of seven payroll objects. The program should ask the user for the number of hours each employee worked and will then display the amount of gross pay each has earned.

Explanation / Answer

#include <iostream>
#include <iomanip>


class Payroll
{
private:
    int hoursWorked;
    double payRate;
    
public:
    Payroll();
    Payroll(int, double);
    void setHours(int);
    void setPayRate(double);
    int getHours() const;
    double getPayRate() const;
    double getGross()const;
};
Payroll::Payroll()
{
    hoursWorked = 0;
    payRate = 0.0;
}
Payroll::Payroll(int h, double r)
{
    payRate = r;
    hoursWorked = h;
}
void Payroll::setHours(int h)
{
    hoursWorked = h;
}
void Payroll::setPayRate(double p)
{
    payRate = p;
}
int Payroll::getHours() const
{
    return hoursWorked;
}
double Payroll::getPayRate() const
{
    return payRate;
}
double Payroll::getGross() const
{
    double gross = static_cast<double>(hoursWorked) * payRate;
    return gross;
}

using namespace std;
int main()
{
int noOfEmp;
cout << "Enter number of employees";
cin>>noOfEmp;

    const int NUM_EMPLOYEES = noOfEmp;
    Payroll employee[NUM_EMPLOYEES];
    int pay;
    int hours;
    int i;
    double grossPay;

    for (i = 0; i < NUM_EMPLOYEES; i++)
    {

        cout << "Enter the # " << (i+1) << " employee's rate of pay per hour: ";
        cin >> pay;
        cout << "Enter the # " << (i+1) << " employee's hours worked for the week: ";
        cin >> hours;

        employee[i].setPayRate(pay);
        employee[i].setHours(hours);       
    }
    cout << " Gross pay for each employee: ";
    cout << fixed << showpoint << setprecision(2);
    for (int i = 0; i < NUM_EMPLOYEES; i++)
    {
        grossPay = employee[i].getGross();
        cout << "The gross pay for employee # " << (i+1) << " is: " << grossPay << endl;     
    }
    return 0;
}

/*output:-

Enter number of employees 1

Enter the # 1 employee's rate of pay per hour: 500

Enter the # 1 employee's hours worked for the week: 45

Gross pay for each employee:

The gross pay for employee # 1 is: 22500.00

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote