### Function problem

I am unsure why my { bracket in my DisplayDeductions function says that it expected a declaration. Also linking my DisplayPay to my DisplayDeductions to transfer the values is not working for me. Any help would be great.

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788`` ``````#include #include using namespace std; const double HOURLYPAY=10.50; void DisplayPay (int hours, double RegPay, double OverTPay, double DOTPay, double Pay, const double HOURLYPAY, double OT, double DTime, double NetPay); void DisplayDeductions(double Taxes, double CPP, double EI, double UD, double Money); void DisplayNetpay(double NetPay); int main() { int hours=0; char repeat = 'y'; //user instructions cout<<"This program will calculate your pay for how many"<>hours; void DisplayPay (int hours, double RegPay, double OverTPay, double Pay, const double HOURLYPAY, double OT, double DTime); //rerun the program cout<<"Enter y or Y to rerun the program, anything else to quit "; cin>>repeat; }while (repeat=='y'||repeat=='Y');//end do-while return 0; }//end main void DisplayPay (int hours, double RegPay, double OverTPay, double DOTPay, double Pay, const double HOURLYPAY, double OT, double DTime, double NetPay) { if(40<=hours)//if hours are less than or equal to 40 { Pay=hours*HOURLYPAY; NetPay=Pay; } else if(40
You have a ";" from coping the function prototype right here:

 ``123456789101112131415`` ``````void DisplayDeductions(double Taxes, double CPP, double EI, double UD, double Money); ^ { Taxes=NetPay*0.31; CPP=NetPay*0.024; EI=NetPay*0.019; UD=NetPay*0.004; Money=Netpay-Taxes-CPP-EI-UD; cout<<"Here are your deductions: "<

And as for the linking, declare the variables in main and then in the function prototype and the function definition, insert a & before the variable name. So like
`void DisplayNetpay(double NetPay);`
would become
`void DisplayNetpay(double &NetPay);`
and you would declare NetPay in int main.
Last edited on
Would I declare my functions before my return and after my while in my int main?
I'm talking about the literal variables. So like here:

 ``1234567`` ``````int main() { int hours=0; char repeat = 'y'; double NetPay; //user instructions ``````

If you wanted to use NetPay in another function, and have your DisplayDeductions function save a new value in the actual NetPay(my new one in int main).

Oh, and you are calling variables that have not been made in int main as well.
So this in int main:
`void DisplayPay (int hours, double RegPay, double OverTPay, double Pay, const double HOURLYPAY, double OT, double DTime);`
Has no values to "carry over" into that function because they haven't been initialized.
Topic archived. No new replies allowed.