Calculating four weeks pay.
I am trying to read four weeks worth of hours from an employee, apply the calcPay function, and total the four weeks to display gross pay for the month. In my code, the calcPay function is only applying to the last week's entry. How do I get it to apply to all four weeks and display the gross pay total? Thanks. //*************************************************** //Determine gross pay for a four-week period based //on hourly rate and number of hours worked each week // with any hours over 40 being paid time-and-a-half //*************************************************** #include <iostream> void calcPay (double, double, double&); //Declaring a function before using & pointer to return const float MAX_HOURS = 40.0; const float OVERTIME = 1.5; using namespace std; int main() { double payRate = 0.0; int weeks = 4; double hours[i] = {0.0}; double wages = 0.0; cout << "Enter pay rate amount:
quot;; cin >> payRate; for(int i=0; i<weeks; i++) { cout<<"Enter "<<(i+1)<<" week working hours: "; cin >> hours[i]; } calcPay(payRate, hours, wages); cout <<"Wages earned this month are " << wages << "."; return 0; } void calcPay (double payRate, double hours, double& wages) { if (hours > MAX_HOURS) { wages = MAX_HOURS * payRate + (hours - MAX_HOURS) * OVERTIME * payRate; } else { wages = hours * payRate; } return; }