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

c++ Payroll. Write a class name Payroll, with the class declaration in a file ca

ID: 671371 • Letter: C

Question

c++

Payroll.

Write a class name Payroll, with the class declaration in a file called Payroll.h and the implementation in a file called Payroll.cpp.

The class will have data members for an employee’s hourly pay rate, number of hours worked and calculate the total pay for the week. All of the data members will be doubles. The class only needs one constructor which can be a default constructor that sets all data members to zero. Then add the mutators and accessor for the class.

The program will have an array of 7 Payroll objects.

The program will prompt the user for number of hours each employee has worked

and will then display the amount of gross pay each has earned.

Before asking the user for the hours, the program should set the pay rate for each employee without user input.

Validation: Do not accept values greater than 60 for the number of hours worked.

Explanation / Answer

#include class Payroll { private: double rate, hours, tpay; public: Payroll(); void setRate(double); void setHours(double); void setTpay(double); double getRate(); double getHours(); double getTpay(); }; // Constructor Payroll::Payroll () { rate = 0; hours = 0; tpay = 0; } // Mutator member functions void Payroll::setRate(double r) { rate = r; } void Payroll::setHours(double h) { hours = h; } void Payroll::setTpay(double t) { tpay = t; } // Accessor member funtions that returns values double Payroll::getRate() { return rate; } double Payroll::getHours() { return hours; } double Payroll::getTpay() { return tpay; } using namespace std; void displaypayroll( Payroll * const); int main() { const int WORKER = 7; // Array of 7 worker's Payroll Payday[WORKER]; // Get worker hours for(int count = 0; count
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