First, let me say I am very new at this... So, I have spent all day working on this and I think I have tried to fix it so many times that I have completely destroyed it now and now I am not sure if it's able to be saved... Anyway, the assignment is to calculate the gross salary, taxes, retirement fund contributions, and net salary for employees of a company and output the results into two output files. One in table format like so: **When I tried to do this originally, it undid all the indentations, so I put in ... to try and keep it somewhat formatted so it might be easier to read. The window on this Yahoo! thing is not quite wide enough, but I think you'll be able to get the idea.** Name.................Gross Salary...Benefits...Contributions.......
Salary Joe Smith............ $6850.00.......$62.50.
Norm Johnson.......Bad Data.......Invalid contribution not qualified John Jordan.........$1050.00...... $0.00.....
Nancy K. Brown.....Bad Data Invalid contribution 6%, Hours invalid And the other one in a detailed format like so: Name:................Joe Smith Gross Salary:........$6850.00 Medical Benefits:..........$62.50 Retirement Contribution: 5% ......Company:......$343.75 ......Employee:......$343.75 ......Total:.................$687.50 Taxes Owed:.........$168.50 Net Salary:.................$6275.25 There are a few more stipulations, but here's the code I have so far (my deepest apologies for how messed up it is right now....when you get to thinking in a circle, you can really mess things up): #include
I have not use getline myself, but that is the way I have seen it used. The do while thing is wrongly done. What you should do is something like this. Make a bool, not a number, to say if the loop is to continue. do - get the input file name. - see if it opens. - if not, - - print error message to user. - - set the bool to false. - else - - set the bool to true. - end if while bool is false (or not bool). Do the same loop structure for each filename you need to get. The way you have it, you are getting the in file. If this is ok, but one of the out files is not, then you are looping around to get the in file again. This maybe causing your infinite loop. There is one problem with doing it this way though. If the user types in the same name of the file, it will continually loop around as the file cannot open.
Source
Help with an infinite loop in my C++ program?
Thursday, March 10, 2011
Posted by
Bobby vaizZ
at
3:15 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment