C++ array issues

I have the code working but it is not what the instructor is wanting. Here is what I am having to do:

Write a C++ console application that asks the user to enter the hourly wage and number of hours worked for each week in a 4-week pay period. Create a custom function with appropriate input parameters and return type that calculates the total gross pay based on the values entered by the user. Use suitable loops for the user input and the processing of data entered by the user. The program should print out the gross pay for the pay period for the employee.

He is wanting an array to pass the information He said "You need a procedural program with a custom function (also called a user-defined function) that calculates the gross pay for the pay period. Remember, the pay period is 4 weeks. This means that you will need to use an array to pass the hours data to the custom function, since the overtime needs to be calculated on a week-by-week basis. To give you an idea, the prototype for the function should be something like:

double calculateGrossPay(float hours[], float rate);"

My code is below on what I have I just do not know how to put in the array he is wanting. Please help I am new at this.


#include <iostream>
#include <iomanip>

using namespace std;

// This is the function that will calculate the salary of the hourly worker.
class EmployeeSalary
{
public:
/* hourly workers*/

double CalculateHourlySalary(double hrRate, double hours)
{
if ( hours <= 40 )

salary = hours * hrRate;

else

salary = 40.0 * hrRate + ( hours - 40 ) * hrRate * 1.5;

return salary;
}





private:
double salary;
};


int main()
{

//Naming the variables so it will be able to hold the information the user is putting in.

EmployeeSalary salary;
double sal;
double hrRate;
double hours;

{


// This is asking for the users input so it will be able to pull the numbers to the function that it is calling for the calculation.

cout<<"Enter Hour Rate:$ ";
cin>>hrRate;
cout<<"Enter hours worked: ";
cin>>hours;
cout<<"Hourly worker's salary is:$ "<<salary.CalculateHourlySalary(hrRate,hours)<<endl;
cout<<endl;
}

return 0;
}
Topic archived. No new replies allowed.