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:
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.
Where did jonnin put it in his code?
You do have a function in your code already (even though it is a class member function). Where is it?
It does seem that you did not gain anything by reading the two tutorials that I did give links to. Why should we continue writing anything, if it is useless?
Do not copy-paste (aka "put") anything anywhere. Try to understand and then use that knowledge.
the c++ compiler / parser really only has 1 rule about what code goes where that you need to know about right now. It has to know what something is before you use it, from the top down and when using multiple files, you have those compiled in an orderly fashion.
so
int main()
...
foo()
}
void foo()
{
}
won't work because you used it in main but it is invented after main.
that is why headers and .h files are useful, you can put the header above main and the body below it if you like:
void foo(); //header has a ; on it, otherwise identical to the function's define line (the type name (args) line)
so the answer is that it really does not matter. As you are beginning you may put them all above main and ignore headers for now, but soon you should learn about those. Get it working using no headers, before main, and once you have that, then maybe put it below main with a header for practice.