Using your previous interactive payroll projects as a baseline (and re-using functions and declarations as much as possible), create a modified payroll program which first reads the employee data (id, code, dependents, lastname, firstname) from a disk file 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).
Using Java, create an Employee object (class) to hold the following private data for one employee:
PURPOSE: Perform weekly payroll processing for a small business.
DESCRIPTION: Obtain pay rate and other employee data from a disk file and hours from keyboard input, then print paychecks and statistics.
Get your program working with a linear search function to lookup the ID.
For extra credit,
to sort the arrays by ID,
and then replace the lookup function with a binary search.
INPUT
FILE INPUT: Assume there is a personnel data file containing the following information record for each employee:
id | Employee ID number |
---|---|
code | 1 if eligible for overtime; else 2 or 3. |
married | (true or false) |
dependents | Number of dependents |
rate | Pay rate per hour |
last | Last name |
first | First name |
middle | Middle name |
KEYBOARD INPUT:
The user will input an ID number and the number of hours worked.
Provide appropriate prompt messages,
and an error message if there is no such ID.
ID numbers (with hours) may be entered in any order.
(It is possible that some employees did not work this week.
It is also possible for the clerk to input an invalid ID #;
decide how to deal with it.)
An ID number of zero indicates the end of keyboard input.
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:
3. Finally, give everybody a 10% raise, with a minimum of one dollar-per-hour. (Do not add this code to the main routine; instead, write a separate function named "raise()", and call it from "main".)
PROGRAM DESIGN
Your program should have a simple main( String[] args ) function
that calls the following functions (where a is the array of Employee objects, and m is the number of used:
// For each one, create a new employee object in the array.
CALCULATIONS
Pay codes are either 1 or 2 or 3, with pay amounts calculated as follows:
Taxes: