![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Error E2314 Assign5.cpp 28: Call of nonfunction in function main()Create a program that calculates the earnings and taxes for workers. The program will have:
a)The main program will read in lines from the terminal, which will prompt the user for this information for each worker: Hourly Salary Hours Exemptions b) The salary will be an hourly salary, and the hours will be the number of hours worked in a week. Your program should include a function for computing the pay for a week. If a person worked at most 40 hours, the pay is the hourly rate times the number of hours. If a person worked more than 40 hours, the pay for the first 40 hours is the regular hourly age, and the pay for overtime, the number of hours worked beyond 40, is 1.5 times the regular hourly wage for that worker. Thus the hourly salary and the number of hours will be arguments of this function. c) Your program should include a second function for computing how much is withheld each week. The pay withheld is 20% of the weekly salary, minus $100 times the number of exemptions, over $600. Examples: if the weekly salary is $750, a worker with 1 exemption pays . A worker with the same salary and 2 exemptions has nothing withheld because . Thus the salary and the number of exemptions (an integer) will be arguments of this function. d)The number of workers will not be given beforehand, so use a while loop that will compute the pay until the user does not type in ‘y’ in response to the question: “Are there any more employees?” Keep track of the number of employees with a counter variable. e)Your output file should consist of a sequence of lines of the form “The salary is $ ####.## and the pay withheld is $ ###.## ”, where the numbers are the pay and the amount withheld for the week. The end of the output file should consist of a line stating the number of employees. You will need the lines #include<iomanip> and cout << fixed << setprecision(2) for this. ---------------------------------------------------------------------- my code is below I can not find what is wrong. CPP / C++ / C Code:
error shown Error E2314 Assign5.cpp 28: Call of nonfunction in function main() Error E2314 Assign5.cpp 30: Call of nonfunction in function main() Error E2040 Assign5.cpp 40: Declaration terminated incorrectly Error E2040 Assign5.cpp 50: Declaration terminated incorrectly Last edited by LuciWiz : 05-Mar-2009 at 04:13.
Reason: Please insert your C++ between [cpp] & ]/cpp] tags
|
|||
|
#2
|
|||
|
|||
Re: Can anyone help me this code?My C++ is pretty rusty but this looks like a simple enough problem. Ignoring the requirements for your program, let's go through your code and see what's wrong with it (so you can have it compile at least).
Quote:
CPP / C++ / C Code:
When you define/declare functions in the global namespace, you don't have to try to tell your main() function that they are functions returning doubles. You already said it once in CPP / C++ / C Code:
So, let's reduce the line to CPP / C++ / C Code:
The first error I get with my g++ 3.4.2 is " main.cpp: In function `int main()': main.cpp:27: error: cannot convert `double (*)(double, int)' to `double' for arg ument `1' to `double T_exemption(double, int)' " So let's see. The line looks like this: CPP / C++ / C Code:
CPP / C++ / C Code:
Let's try to compile again. This time I get " main.cpp:37: error: expected unqualified-id before "if" main.cpp:37: error: expected `,' or `;' before "if" main.cpp:41: error: expected unqualified-id before "else" main.cpp:41: error: expected `,' or `;' before "else" main.cpp:47: error: expected unqualified-id before "if" main.cpp:47: error: expected `,' or `;' before "if" main.cpp:51: error: expected unqualified-id before "else" main.cpp:51: error: expected `,' or `;' before "else" " I think basically it's saying it's pretty unexpected to see an if-else construct in the middle of nowhere. So let's see. You have CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
Output: Code:
Note that this has nothing to do with the requirements of your program, just getting it to compile. You could also pay attention to your naming to make the code more readable. Compare CPP / C++ / C Code:
CPP / C++ / C Code:
Or compare functions CPP / C++ / C Code:
CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
Re: Can anyone help me this code?Thank you very much Kimmo !!!!!!!!!!
I love you |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trouble integrating console code into GUI | Barman007 | Java Forum | 18 | 15-May-2008 14:05 |
| How to sort random access file? | wmmccoy0910 | C Programming Language | 12 | 04-Sep-2006 04:40 |
| Here it is again! 35% - 40% off For Life! | my-e-space | Web Hosting Advertisements & Offers | 0 | 20-Apr-2006 15:48 |
| Guidelines for posting requests for help - UPDATED! | WaltP | C Programming Language | 0 | 21-Apr-2005 03:44 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The