CM16 Project - Payroll using employee database

CM16 PROJECT:   Payroll Program using employee database.

Using your previous interactive payroll projects as a baseline (and re-using functions and array declarations as much as possible), create a modified payroll program that first reads an "employee database" file into arrays, and then interactively accepts input about employee hours (by ID, in any order). After all of the hourly data has been input by the Payroll Clerk (user), your program should then print all of the paychecks in ID order (skipping any where the pay is zero). Finally, print statistics about the entire payroll (see below).

For extra credit, sort the ID array and use a binary search.



SPECIFICATIONS

PURPOSE

Read pay rate and other permanent data for all employees, into arrays.
Then obtain hours from keyboard input.
Finally, print the paychecks and statistics.

First, get your program working with a linear search function to lookup the ID.
For extra credit, to sort the arrays by ID using "quicksort",
and then replace the lookup function with a binary search.


INPUT

KEYBOARD INPUT:

First, the user shall be asked for the name of the employee database file. If the file exists, it shall be read into the arrays.

After the database has been read into the arrays, the user shall be prompted to enter the ID number and the number of hours worked for each employee. Provide appropriate prompt messages, and an error message if there is no such ID. ID numbers (with hours) may be entered in any order, and it is possible that some employees did not work this week. An ID number of zero indicates the end of keyboard input.

FILE INPUT: For each employee, the database file shall contain the following information:

id Employee ID number integer
code 1 if eligible for overtime; else 2 or 3. integer
dependents Number of dependents. integer
rate Pay rate per hour float
last Last name string char []
first First name string char []

You may make the following assumptions about the employee database:

  • All ID numbers are greater than zero.
  • Name strings (firstname, lastname) are no longer than two dozen characters each.
  • Name strings contain no blanks or punctuation (or that each string is surrounded by quotes).
  • After the last employee data record, there is an additional dummy record with an ID number of zero.

    OUTPUT

    1. Print a (simulated) paycheck for each employee who worked this week (pay greater than zero). Each paycheck should show the following:

    2. After all paychecks are printed, display the following statistics:


    PAY CALCULATIONS

    Pay codes are either 1 or 2 or 3, with pay amounts calculated as follows:

    1. OVERTIME: If pay code is 1, then pay time-and-a-half for hours over 40.
    2. EXEMPT: If pay code is 2, all hours worked are paid at straight-time.
    3. MANAGER: If pay code is 3, pay 40 hours (and use 40 hours in statistics), regardless of hours reported.

    DEDUCTIONS

    The deduction amount depends upon the number of dependents. The first $100 is tax exempt, and $50 per dependent is also tax exempt. Assume a flat tax rate of 17% on the remainder. Tax is zero if exemptions exceed income.

    Examples: With 4 dependents, the first $300 is tax exempt ($100 + 4 * $50). If income is $500, then tax is 17% of $200. If income is $200, there is no tax.


    PROGRAM DESIGN

    Your program should have a simple main() function that calls the following functions:
    int getdata() Read employee data from a file.
    (Return number of employees on file.)
    prepare() Sort arrays by ID. [Extra credit.]
    int gethrs() Input the hours for each employee who worked.
    (Return number of employees who worked.)
    calcpay() Calculate the payroll.
    deduct() Calculate the deductions.
    paychex() Print the paychecks & paystubs.
    stats() Display statistics.