Programming assignment help/advice?


Write a C++ program to process payroll. Raw payroll input data is stored in the file: payData.txt. This file contains the following fields:


-Employee ID
-Code for employee classification (H for hourly, S for salaried)
-If hourly, two fields follow: hours worked and hourly pay rate
-If salaried, only one field follows: annual salary

Your program should gross pay for each employee. For hourly workers, gross pay is the number of hours worked times pay rate. The employee should receive "time-and-a-half" for overtime (i.e. 1.5 times the hourly pay rate for all hours in excess of 40 hours). For salaried workers, the gross pay for that pay period is their annual salary (read from the input file) divided by 26 (the number of pay periods in a year).

Tax will be withheld for each employee. The tax will be calculated using the following:

If gross pay is ... Tax Withheld is
$925 to $2860 $138.75 plus 28% of amount over $925
over $2860 but no greater than $4100 $680.55 plus 32% of amount over $2860
over $4100 40% of gross pay
Net pay will then simply be the gross pay minus the tax to be withheld.

Write an organized and formatted report to console output including column headings, proper formatting of dollar amounts, adequate spacing, etc. Your report could look something like:

Employee ID Gross Tax Net
XXXXXX XXX.XX XXX.XX XXX.XX
XXXXXX XXXX.XX XXX.XX XXX.XX

At the end of the report, include one additional line with totals of the gross pay, tax, and net pay under the appropriate columns with an appropriate label.

Assume that all input data have been validated, so no further error checking is necessary
=================================================================================
Data being read in:
101456 H 20 6.57
100045 S 81994.12
100321 H 45 23.50
101987 H 39 15.76
100486 S 116935.65
100357 H 50 18.19
102003 H 30 12.75
123887 S 226345.43
110441 S 54783.28
101119 H 35 22.22
114532 S 152573.23
100003 H 40 19.00
101285 H 60 29.95
105539 S 100284.54
176531 S 78546.77
101119 H 38 43.15
=================================================================================
So that is what I need to accomplish with this assignment. Now I have yet to start coding this because I am unsure on how I will be able to read in the file when the hourly and salary employee data have different types of data. Any advise would be helpful.

Thanks
Last edited on
Write a C++ program


Now that is your job, not ours.

Do have any code at all?

So you need to identify what variables data types / structures you need to store the info.

You then need to identify what functions you need.

I find it helps to write out your methodology with comments. This can be done incrementally - so start with very general ideas first, go back and put in more detail until you are happy to write code.

This helps to organise your thoughts logically, and identify functions.

If there things you are unsure of, then make use of the reference section at the top left of this page, and Google.

Schools normally give enough info for students to be able to do assignments, so go to the lectures & tutorials (Don't sleep through them)
Thanks for the your post. My question is in the last section. I am not asking anyone to write the program for me. This is just the assignment i copied over... If someone could help me reading data from a file with two different types of data I can probably code up the rest...

This is something we have not done in class, we have only read data from text files with all the same type of data. As for just doing a google search, trust me i've been doing that for the past few hours.
Last edited on
I am going to try and explain myself a little better. I need to read data from a file with hourly and salary employee's. I have no idea how I would be able to read both of these types of data and then later be able to use them in calculations for such things like tax and net pay.

thanks
Last edited on
You need a class for the employee. It will have member variables for the info you need to store.

Read from the file to put the info into an employee object. You can use cin on the file stream, in just same way as you would normally.

Next put each employee object into a vector.

Go through the vector and do whatever calculations are necessary. Be careful comparing doubles - it should not be done directly.

Post your code, so we can see how you got on.

HTH
Topic archived. No new replies allowed.