### payroll calculator

I'm trying to get my payroll calculator to show the regular and overtime hours but after you enter hours worked it asks enter Y to rerun. I'm trying my hardest to understand functions but obviously there is something wrong with the code. Could someone PLEASE HELP me with this? It would be greatly appreciated:)

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990`` ``````#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, 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); void DisplayDeductions(double &Taxes, double &CPP, double &EI, double &UD, double &Money, double &NetPay); //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
Line 31: This is not how you call function.
Look:
 ``12345678`` ``````void foo(int bar); //This is function declaration. It tells compiler that there is such function somewhere void foo(int bar) { //This is function definition. It contains all statements which will be executed. } foo(baz);//This is function call. It executes function. ``````
Ok so lines 31 and 33 should look like

 ``123`` ``````void DisplayPay (hours, RegPay, OverTPay, Pay, HOURLYPAY, OT, DTime); void DisplayDeductions(Taxes, CPP, EI, UD, Money, NetPay);``````
yes, something like that
Alright that makes a lot more sense. But with what I did is I removed the void in front and I'm getting errors along the RegPay, OverTPay, ect, ect...

They are apparently all undefined except for hours and HOURLYPAY as these are defined in main().
Last edited on
Well, you are never defined them, so...
So what your saying is I need to define them on the top as well as in the functions?
Yes.
does this look right?

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192`` ``````#include #include using namespace std; const double HOURLYPAY=10.50; double RegPay, OverTPay, DOTPay, Pay, OT, DTime, NetPay; double Taxes, CPP, EI, UD; 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, double NetPay); int main() { int hours=0; char repeat = 'y'; //user instructions cout<<"This program will calculate your pay for how many"<>hours; DisplayPay (hours, RegPay, OverTPay, Pay, HOURLYPAY, OT, DTime); DisplayDeductions(Taxes, CPP, EI, UD, NetPay); //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
1) Why are you passing parameters which you will never use?
`void DisplayPay(int hours, const double HOURLYPAY);` — this is ALL you need. Other variables should be local.
 ``12345678910`` ``````void DisplayPay(int hours, const double HOURLYPAY) { int pay(0), netPay(0), overtime(0), overtimePay(0), dTime(0); if(40<=hours) { pay=hours*HOURLYPAY; netPay=pay; } else if (40 < hours && hours <= 45) { //There was an error in your code. pay = (HORLYPAY * 40); //... }``````
Alright, all fixed. One error that has me completely baffled. I have never seen this error.

error LNK2019: unresolved external symbol "void __cdecl DisplayDeductions(double,double,double,double,double)" (?DisplayDeductions@@YAXNNNNN@Z) referenced in function _main
Check your DisplayDeductions function declaration, definition and call
Got it working Thanks for your help.
Topic archived. No new replies allowed.