Object: To process the weekly payroll in a company of 10 employees. Each employee has worked one or more days in the week and the number of hours of work per day is a number from 1 to 8. The dummy value -99 is used to end the listing ofthe hours worked in a week.

For this assignment, you will need the following structures:

  • The structure Date defined in the header file Date.h.to hold the information about a date.
  • The structure EmployeeInfo defined in the header file EmployeeInfo.h to hold the information about an employee.

Write and test each of the following functions:

Function int readHours( ) reads one or more hours worked by an employee in the week, computes their sum and returns it. The list of hours is terminated by the dummy value -99. Example: 8 5 7 7 -99 To test this function, write a function main that calls it and prints the total number of hours.

Function EmployeeInfo readInfo() reads an employee's id number, first name, last name, data of birth, hire date, and pay rate, and then calls function readHours( ) to read the hours that he has worked during the week and returns their sum. Function readInfo( ) then places all this information in an Employeelnfo structure and returns it.

To test this function, write a function main that calls it and prints the employee's id number, first name, last name, data of birth, hire date, pay rate, and the total number of hours of work. The input data should be like the following: 58243 John Doe 10 251981 6152005 8.75 7478 -99

Function void printInfo( EmployeeInfo emp) receives as argument an EmloyeeInfo structure and prints the values of its member variables as follows:

Doe, John ID: 12345
DOB: 1012511989
BOH: 711412007
Pay Rate: $ 15.50 Hours: 36

To test this function, write a function main that initializes the member variables of a structure EmployeeInfo and then call the function to print the values of these member variables.

Function donble computeTax( donble pay) receives as argument an employee's gross pay, computes his tax deduction, and returns it. The tax deduction is computed 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.

To test this function, write a: function main that calls it with a gross pay and then prints the tax deduction returned by the function.

Function void compnteTaxNetPay(donble gpay, donble & tax, donble &npay) that receives as argument an employee's gross pay, computes his tax deduction (by calling function computeTaxO, and his net pay and returns them using the reference parameters. The net pay is the gross pay minus the tax deduction To test this function, write a function main that calls it with a gross pay and then prints the tax deduction and the net pay that the function returns.

Place the functions readHours(), readInfo(), and printInfo() in the source file employee.cpp, and their function prototypes in the header file employee.h. Since you are doing I/O in some of these functions, you must also include in the header file employee.h and the header files iostream and iomanip. Note that the header file Date.h is included in the header file EmployeeInfo.h, EmployeeInfo.h is included in the header file employee.h and employee.h included in the source file employee.cpp.

Place the functions computeTax() and computeTaxNet() in the source file payroll.cpp, and their function prototypes in the header file payroll.h. Note that the header file payroll.h must be included in the source file payroll.cpp.

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

58243 John Doe 10 25 1981 6 15 2005 8.75 7 6 7 8 -99

Is for an employee with ID number 58243; first name: john; last name: doe; date of birth: 10/25/1981; date hired 6/15/2005; pay rate $8.75; who has worked 4 days for 7, 6, 7, and 8 hours respectively.

Type your function main and place it in the file lab4.cpp. Note that you must include in this file the header files employee.h and payroll.h

Your function main does the following in the loop:

  • read the information about an employee by calling function readInfo().
  • Print the information about an employee by calling function printInfo().
  • compute his gross pay and print it.
  • compute his tax deduction and net pay(by calling function computeTaxNetPay()) and print them. It also computes the total gross pay and the total tax deduction of the company and prints them.

Execute your program 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 Rage: $15.50
Hours:36
Gross Pay: $558.00
Tax: $55.80
Net Pay: $502.20

Leave at least two blank lines between the employees.

Return the source files, the header files, the input file, and the output file in this order.

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.