Programming
Assignment 13
The Heartwick Teddy Bear Manufacturing
Company has hired you to develop a payroll system for them. Your program is to do the following things.
1. For all employees (read until the end
of the file is encountered)
a. Read
and print the employee's name
b. Read
the employee's hours worked, pay rate, and number of dependents.
c. Calculate
and print the employee's regular
pay, overtime pay, and total pay.
d. Calculate
the employee's tax and net pay (net_pay = total_pay - tax).
Print tax and net pay.
2. Print the highest, lowest, and average net pay for all the employees.
Your output should have
appropriate headings and labels.
Use the following functions in your
program.
void ReadWriteName()
void CalculatePay(int hours, float rate,
float& regular_pay,
float& overtime_pay)
float Tax(float total_pay, int dependents)
The CalculatePay function
calculates and returns regular_pay
and overtime_pay: regular_pay
is rate * hours (or rate * 40 if there is overtime); overtime_pay is 1.5 * rate * (hours - 40) for hours over 40 (zero otherwise). Total pay is calculated in main as
the sum of regular_pay and overtime_pay. The Tax function calculates taxable_pay and returns tax: taxable_pay
is total_pay - 50 * dependents; tax is calculated by applying the
appropriate tax rate from the following table (tax is taxable_pay *
tax_rate).
Taxable
Pay Tax
Rate
$0.00
to $250.00 10%
$250.01
to $599.99 15%
$600.00
and up 20%
Input
Data
Name Hours Rate Dependents
Donald Duck 45 10.00 4
Goofy Dog 25 8.00 1
Mickey Mouse 35 11.50 1
Minnie Mouse 50 12.00 1
Bugs Bunny 40 9.95 1
With the UNIX operating system, we can
write our programs using only cin
and cout instead of infile and outfile. If you do this,
you can run this program by typing a.out
< prog15.dat This will use prog15.dat as input and print your output on the screen. If you also want your output to go to a
file, you can type a.out < prog15.dat
> prog15.out (The operators < and >
are called "redirection operators" in UNIX. )