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:
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
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:
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:
Execute your program using I/O redirection. The output should look like the following (for each employee):
Pay Rage: $15.50
Gross Pay: $558.00
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.