Enter employee ID:
100
Enter number of hours worked:
45
Enter hourly wage:
15
Employee ID: 100
Net pay: $336.426
Average amount paid: $-1.#IND- I need help fixing this as well.
Total payroll: $336.426
Do you want to enter another employee? (y/n)?
y
Enter employee ID:
200
Enter number of hours worked:
30
Enter hourly wage:
13
Employee ID: 200
Net pay: $389.071
Average amount paid: $336.426
Total payroll: $725.496
Do you want to enter another employee? (y/n)?
Try printing the hours worked and hourly wage. I think you'll find that they aren't changing.
The problem with average amt paid being funny is because you're dividing by emp_count which is zero the first time through the loop. Increment emp_count before you divide.
Enter employee ID:
1
Enter number of hours worked:
45
Enter hourly wage:
13
Employee ID: 1
Net pay: $291.261
Average amount paid: $291.261
Total payroll: $291.261
Do you want to enter another employee? (y/n)?
y
Enter employee ID:
23
Enter number of hours worked:
30
Enter hourly wage:
15
Employee ID: 23
Net pay: $449.194
Average amount paid: $370.228
Total payroll: $740.455
Do you want to enter another employee? (y/n)?
Why am I getting the same amounts for the first employee?
The point is that the first time through the loop you have only one employee. With just one employee, the net pay, payroll, and average pay amount will be the same. If you have one employee who makes $100 then your total payroll is $100, and your average salary is $100. So the numbers should be the same.
But let's look at the calculations. I think they may be wrong:
Line 2: usually "overtime pay" is pay for work done in addition to the normal 40 hrs. It's calculated at 1.5 time the normal rate, but that multiplier only applies to the time over 40 hours. You're applying it to all the time worked.
Line 3: Gross salary is less than overtime pay? That doesn't seem right.
Line 4: What is this formula? Where does it come from?
Can you post the assignment? It's difficult to tell if your results are wrong without knowing what they are supposed to be.
Write a program to process weekly employee time cards for all employees of an organization. For each employee, program needs to collect three data items – an identification number, hourly wage rate and number of hours worked during a given week. Each employee is to be paid time and a half for all hours worked over 40. A tax amount of 3.625 percent of gross salary will be detected. The program output should show the employee’s number and net pay. Display the total payroll and the average amount paid at the end of the run.
And the fact that total payroll and average amount paid should be displayed only once at the end of the run.
As for the formulas, it says "Each employee is to be paid time and a half for all hours worked over 40." Also, I think the tax means that you should subtract 3.625% of the gross salary from the pay.
A tax amount of 3.625 percent of gross salary will be detected.
This is ambiguous and I urge you to get clarification from the professor. Is the tax paid by the employee or the employer? If it's paid by the employee then it should be subtracted from the employees net pay. If it's paid by the employer then it should be added to the total payroll cost. Also I think the "average amount paid" is the average gross salary since that is the amount paid by the employer. The average net salary is the average amount received. You might seek clarification of this too.