![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Write function getHoursRate that asks to inp the inp variables to initiliaze in mainConsider the definition of the function main:
int main () { float rate, hours; float amount; . . . } Write the following definitions: a. Write the definition of the function getHoursRate that prompts the user to input the hours worked and rate per hour to initialize the variables hours and rate of the function main. b. Write the definition of the value-returning function paycheck that calculates and returns the amount to be paid to an employee based on the hours worked and rate per hour. The hours worked and rate per hour are stored in the variables hours and rate, respectively, of the function main. The formula for calculating the amount to be paid is as follows: for the first 40hours, the rate is the given rate; for hours over 40, the rate is 1.5 times the given rate. c. Write the definition of the function printCheck that prints the hours worked, rate per hour, and the amount due. d. Complete the definition of the function main that tests each of these functions. THIS IS MY PROGRAM AND I KEEP GETTING THE SAME ERRORS: error C2660: 'getHoursRate' : function does not take 0 arguments error C2660: 'paycheck' : function does not take 0 arguments error C2660: 'printCheck' : function does not take 0 arguments error C2082: redefinition of formal parameter 'rate' error C2082: redefinition of formal parameter 'hours' CPP / C++ / C Code:
Last edited by LuciWiz : 10-Nov-2009 at 08:08.
Reason: Please insert your C++ code between [cpp] & [/cpp] tags
|
|||
|
#2
|
|||
|
|||
Re: Write function getHoursRate that asks to inp the inp variables to initiliaze in mainI tries doing this:
CPP / C++ / C Code:
and i got these errors: error C2082: redefinition of formal parameter 'rate' error C2082: redefinition of formal parameter 'hours' error C2082: redefinition of formal parameter 'amount' error C2660: 'paycheck' : function does not take 0 arguments error C2660: 'printCheck' : function does not take 0 arguments Last edited by LuciWiz : 10-Nov-2009 at 08:09.
Reason: Please insert your C++ code between [cpp] & [/cpp] tags
|
|
#3
|
|||
|
|||
Re: Write function getHoursRate that asks to inp the inp variables to initiliaze in mainYou will need to find a way to return the hours and rate variables back to the main() function. You should either pass the parameters by reference or pass the pointers to them:
CPP / C++ / C Code:
CPP / C++ / C Code:
|
|
#4
|
|||
|
|||
Re: Write function getHoursRate that asks to inp the inp variables to initiliaze in mCPP / C++ / C Code:
i did this it finishes compiling without errors but their a runtime error Code:
Last edited by admin : 11-Nov-2009 at 04:27.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|
#5
|
|||
|
|||
Re: Write function getHoursRate that asks to inp the inp variables to initiliaze in mCPP / C++ / C Code:
I'v Also Tried this which works but this time it returns wrong answers Last edited by admin : 11-Nov-2009 at 04:28.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|
#6
|
|||
|
|||
Re: Write function getHoursRate that asks to inp the inp variables to initiliaze in mainRead my previous post. You must either pass by reference or pass the pointer in. Otherwise, your variables will never be filled with meaningful values. See this for more information. Also, when posting code, use CPP tags around it.
|
Recent GIDBlog
Vista ?Widgets? on Windows XP by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Free a malloc returned in a function | james_bond | C Programming Language | 4 | 06-Jan-2008 13:59 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| Help! Some basal questions about MFC | xutingnjupt | MS Visual C++ / MFC Forum | 1 | 05-Dec-2004 03:38 |
| How to write output with a function | jenmaz | C Programming Language | 8 | 17-Nov-2004 23:01 |
| Another problem dealing with main() and driver function | tommy69 | C Programming Language | 4 | 20-Mar-2004 19:46 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The