cout << " Please Check the Output File! " << endl;
cout << endl;
cout<< "Created by : Stanley Patela " << endl;
system("PAUSE");
return 0;
}
the question is as fallows
Write a complete program including comments to compute a weekly payroll. The program reads in information for each of the employees of a company and then prints the results. The program does the following for each employee:
a. First, it reads in the data for each employee. Each employee has a three digit identification code (an integer from 100 to 999), hours worked, rate of pay, and union status (1 if the employee is in the union, 0 if not). For example, here are data valued for two typical workers:
123 46 6.50 1
456 32.12 3 0
b. The program computes the weekly pay, which comes from the following formula (this includes an overtime bonus of time and a half for each hour over 40):
if hours are less than or equal to 40, weekly pay is hours times rate
but
if hours are more than 40 hours, weekly pay is 40 times the rate plus the number of overtime hours times 1.5 times the rate.
Example: ID number 123 would get 40 * 6.50 + 6 * 1.5 * 6.50.
c. The program computes the union dues, which are 10 percent of the weekly pay for union members, and $5 for nonunion members.
d. The program computes net pay, which is weekly pay minus union dues.
e. The program prints all the data values read in and the words "Union" or "Nonunion", plus each item that has been computed. Make sure that all money amounts have exactly two decimal places.
Data: Make sure you handle at least 6 employees. Have at least two employees that are union members and two that are not. Make sure at least 3 employees get overtime.
Output: Create a good looking report. There should be a grand total at the bottom of the report for the total pay, union dues and net pay.
Read the data from an input file - Use the eof function.
Make sure that either a 1 or a 0 is entered for union status. If it is not a valid entry set your dues = 0.
Sample Output:
WEEKLY PAYROLL
Union
ID No. Hours Rate Pay Member Dues Net
110 40.00 10.50 420.00 Yes 42.00 378.00
120 36.00 13.00 468.00 Yes 46.80 421.20
135 46.00 11.25 551.25 No 5.00 546.25
140 42.50 12.50 546.88 No 5.00 541.88
142 45.20 13.00 621.40 Yes 62.14 559.26
145 37.00 11.25 416.25 No 5.00 411.25
15 9.00 9.36 84.24 Unknown 0.00 84.24
Totals 3108.02 165.94 22942.08
i have spent countless hours trying this on my own, and just gave up. any help would be appreciated. I want to learn this, so please explain what you are telling me. thank you for all your help
Well, what I would do is use getline() to get a line of the file at a time, and then use the std::string member functions to parse/split it into each part, then do whatever is needed based on what you get.
You are not saying what is not working.. so we readers need to guess
You should always initialize your variables and declare them only where you need them, never at the top of a function. It makes the code easier for others to read and more reliable.
The second 'inifile << .. line' will never be reached so you will only be reading one line due to the break statement before.