Object: To process the weekly payroll in a company of one or more employees. Each employee has worked 5 days in the week and the number of hours of work per day is a number from 1 to 8.

The information about a date is the same as in Lab2: So you will use the structure in the header file Date.h.

For this assignment, you will use the structure Employeelnfo defined in the header file Employeelnfo.h to hold the information about an employee.

Create and save in your C$240 directory the file lab3.input that contains the information about the employees: use one line of input for each employee. For example:

58243 John Doe 10 25 1981 615 2005 8.75 7475 8

Is for an employee with ID number: 58243; first name: John; last name Doe date of birth: 10/2511981, date hired: 6/1512005; pay rate: $8.75; who has worked for 7, 4, 7, 5, and 8 hours respectively.

NB: The dummy ID number -99 is used to end the input data.

Write a program that does the following for each of the employees:

reads the information about the employee: the number hours read in a loop and their sum is stored in the structure as the number of hours worked during the week.

computes his/her gross pay: the gross pay is the pay rate times the number of hours work.

computes his/her tax deduction as follows:

  • If gross pay is greater than or equal to 1000, 20% of the gross pay;
  • If 800 <= gross pay < 1000, 18% of gross pay;
  • If 600 <= gross pay < 800, 15% of gross pay;
  • otherwise, 10% of the gross pay;

The net pay is the gross pay minus the tax deduction.

Also compute the total gross pay and total tax deduction of the company and print it.

Compile, link and execute your program in UNIX computer using I/O redirection.

The output should look like the following(for each employee):

Doe, John
ID: 12345
DOB: 10/25/1989
DOH: 7/14/2007

Pay Rate: $15.00
Hours: 36
Gross Pay: $558.00
Tax: $55.80
Net Pay: $502.20

Leave two lines between the employees. Return the source file, the header files, the input file, and the output file in this order.

Extra Credit: rewrite the program by assuming that each employee can work one or more days. Use the dummy hours -99 to end the input of an employee's number of hours. For example the information about an employee who has worked only three days is as follows:

58243 John Doe 10 25 1981 6 15 2005 8.75 7 4 7 -99
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.