Hello, I am a newbie at this and I am struggling on how to start this. I had inFile my salary.txt as shown below and I know you string in department and int the hours, salary, and number of employees for each of the pay grade.
I know you do an if statement as so as I outlined it:
if(line is department name)
//do something/action
//output all the accrued data
//output department name
//zero out all the variables
Else if (line is EOF)
//we are done (final output)
Else
//must be an employee
//figure out what the employee is
//add hours, salary to the appropriate value
However I am struggling on actually how to write the code for it to work. Can someone please help and show me how to start off?
salary.txt file:
The A Department
Adam 8 7 8 9 7 F1
Amy 205103 0.08 F3
Angel 8 8 7 8 8 F2
Aaron 10 10 9 6 9 F2
Art 9 8 10 9 9 4 1 F4
The C Department
Cherry 88840 0.105 F3
Cat 105203 0.085 F3
Candy 8 6 7 6 9 F2
Cerry 309011 0.045 F3
Cony 9 8 9 9 9 5 1 F4
EOF
Last in the row after the hours comes the pay grade (F1, F2, F3, F4). The number of hours recorded is based on the pay grade of the employee. F1 and F2s will have 5 numbers for their hours. F3s are commission based where a sales amount and a commission percentage is given. F3s are also assumed to work 30 hours if their commission is 10% or below and 40 hours if their commission is above 10%. F4s will have 7 numbers (as they are on-call during the weekend). Each of the pay grades will also have different pay calculations which are as follows:
F1 = The total number of hours * 10.25
F2 = (The total number of hours – 35) * 18.95 + 400
F3 = The total sales amount * the commission rate
F4 = The first 5 hourly totals * 22.55 + Any remaining hourly totals * 48.75
It should output as so:
The B Department
Total Salary: $##.##
Total Hours: ###
Total Number of Employees: ##
F1: Total Salary: $##.##
Total Hours: ###
Total Number of Employees: ##
(and the rest for F2, F3, F4)
You will probably hate me for this, but this other homework topic has step by step spoon feeding instructions to how to do file processing that is very similar to yours, just for you :) http://www.cplusplus.com/forum/general/235111/