Help with Return and Void functions

Been fighting this for about an 2 hours now and could use a little help please...getting these errors:

payroll.cpp(10): error C2062: type 'double' unexpected
payroll.cpp(19): error C2065: 'rate' : undeclared identifier
payroll.cpp(26): error C2065: 'grosspay' : undeclared identifier
payroll.cpp(26): error C2065: 'rate' : undeclared identifier
payroll.cpp(27): error C2065: 'grosspay' : undeclared identifier

#include <iostream>
using namespace std;
double crate, chours, cgpay;
double calcgpay (double crate, double chours);
void prtgpay (double catchgpay);
int cstudid;

int main() {
int studid, supid, hours,
double grosspay, rate;

cout<< "Enter Student ID#: ";
cin>> studid;

cout<< "Enter Supervisor's ID#: ";
cin>> supid;

cout<< "Enter Students hourly pay: ";
cin>> rate;

cout<< "Enter hours worked: ";
cin>> hours;


//call
grosspay = calcgpay (rate, hours);
prtgpay (grosspay);

system ("PAUSE");
return 0;
}
double calcgpay (double crate, int chours, double cgpay ){
double gpay;
gpay = crate * chours;
return gpay;
}
void prtgpay (double catchgpay){

cout<< "Student "<< cstudid << "Pay Rate "<< crate << "Hours worked " << chours << "Gross Pay" << catchgpay <<endl;
}
Last edited on
int studid, supid, hours,

you need a semi-colon at the end . NOT a comma.

use code tags too :)

edit:
1>k:\c++\payroll\payroll\payroll.cpp(10): error C2062: type 'double' unexpected


The compiler tells you the line (or fairly near to) where things are not right.
Last edited on
code tags?

like this?

//call

and many thanks.
no. like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
using namespace std;
double crate, chours, cgpay;
double calcgpay (double crate, double chours);
void prtgpay (double catchgpay);
int cstudid;

int main() {
int studid, supid, hours, 
double grosspay, rate;

cout<< "Enter Student ID#: ";
cin>> studid;

cout<< "Enter Supervisor's ID#: ";
cin>> supid;

cout<< "Enter Students hourly pay: ";
cin>> rate;

cout<< "Enter hours worked: ";
cin>> hours;


//call
grosspay = calcgpay (rate, hours);
prtgpay (grosspay);

system ("PAUSE");
return 0;
}
double calcgpay (double crate, int chours, double cgpay ){
double gpay;
gpay = crate * chours;
return gpay;
}
void prtgpay (double catchgpay){ 

cout<< "Student "<< cstudid << "Pay Rate "<< crate << "Hours worked " << chours << "Gross Pay" << catchgpay <<endl;
}


It makes your code look clearer. Just select '<>' Source Code option from the format menu on the right ->>>>
got it, thanks. Fixed the @#%$& semi colon. Hate that, makes me feel like a moron. Now I have

error LNK2019: unresolved external symbol "double __cdecl calcgpay(double,double)" (?calcgpay@@YANNN@Z) referenced in function _main
fatal error LNK1120: 1 unresolved externals

Having a really time grasping functions...can't seem to find an explanation that's making them click for me. any help is extremely appreciated.
You've declared calcgpay to take two parameters:

double calcgpay (double crate, double chours);

and you're calling it with two parameters:

grosspay = calcgpay (rate, hours);

However, your definition has three parameters:

double calcgpay (double crate, int chours, double cgpay ){

So the linker is looking for a function called calcgpay that takes two parameters, but can't find a definition for such a function, because there isn't one.
Got it to run. Still needs some tweaking, but I think I'm out of the weeds now, Thanks a lot guys!!!!
You're welcome :)
Topic archived. No new replies allowed.