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