----------------------------------------------------------------- Program requirements for the Payroll Processing Program - EZPay ----------------------------------------------------------------- A. Program 1. FUNCTIONS: The EZPay program takes an input "timesheet" file containing a list of employees with their hourly wage followed by the hours they worked each day during the week and calculates the employee's end-of-week paycheck amount. The output is a single report file that lists the employees in alphabetical order and tabulates their total hours worked for the week with their paycheck amount. Additional Details: o Overtime pay, calculated as "time-and-a-half" for the extra time beyond 40 hours in a week, automatically accrues for each employee if their total hours exceed 40 hours. o Rudimentary error checking prevents data entry mistakes from entering into the final calculation. 2. INPUT: EZPay is a command-line tool that is designed to be invoked from the shell with the following syntax: ezpay [-v] [input [output]] ezpay [--help] If invoked with the "--help" flag, then an informative description about ezpay is printed (see message at end of spec.) and no processing takes place. For normal operation, EZPay expects one optional flag and up to two file parameters (the "--help" flag is not available in this mode). The flag "-v" indicates verbose mode, which prints out messages while processing the timesheet file. EZPay should still process the input file normally when in verbose mode. The first file parameter is the name of the input file, and the second is the name of the output file. If only one file is supplied as an option, EZPay will use that as the input file and will default to creating an output file called "ezpay.out". If no file parameters are supplied, EZPay will attempt to read the input file "ezpay.in" and again create the default "ezpay.out" output file. EZPay's behavior for any other combination of command line arguments (e.g. greater than three arguments) is undefined. o If the user does not supply a name for the input file, EZPay will look for a file called "ezpay.in". If the input file cannot be found or is not readable, EZPay's behavior is undefined. In addition, the behavior of ezpay when given an empty input file is undefined. o The format of the input file is a list of employees (one employee per line); Each line consists of eight fields. Each input field may be separated by one or more whitespace characters: [ \t\r\n]. o The eight input fields of a line in the input file consist of 2 names (first and last), 1 hourly wage, and 5 days of hours worked, Monday through Friday. Any deviation from this format will result in a format error. o The employee's name is entered as first name followed by last name. The number of characters in the first and last name may not exceed 15 for each name. If a name exceeds 15 characters, it is considered a format error. Names may only consist of the following characters [-a-zA-Z0-9.]. o The hourly wage must be entered without the dollar sign $ in a numeric form that may be converted to a decimal value. For example, $10/hour would normally be entered as "10.00". The wage must be a nonnegative number and may not include "fractional" pennies. Both of these problems are considered data errors. o The hours worked each day are entered in integer format. The number of hours is not to exceed 24 in any given day, and the number of hours may not be negative. Non-integer hours are considered format errors. Hours outside of the specified legal values are data errors. o Blank lines in the input file will be treated as format errors. Furthermore, only the following characters are legal in the input file: [-a-zA-Z0-9. \t\n\r]. If a line contains a character outside of this character class, a format error will be generated for that line. 3. OUTPUT: EZPay creates a single output file using the supplied output file name or "ezpay.out" by default. o The output file will be overwritten if it exists. If the specified output file cannot be created or is not writeable EZPay's behavior is undefined. o This file contains a report of all the employees sorted into alphabetical order by last name and then by first name (with no distinction for upper/lower case letters). Included in the report are each employee's hours worked for that week plus their paycheck amount. A summary at the end of the file tallies the total hours worked and the total disbursement for all employees for that week. Note: when computing wages, fractional amounts beyond the second decimal point will be rounded using a "half round up" strategy. That is, a number will be rounded to its nearest neighbor, unless both neighbors are equidistant, in which case the number will be rounded up. Thus, 10.012 will be rounded to 10.01 while 10.015 will be rounded to 10.02. o Each line of the output file consists of three columns, separated by 1 space and labeled Name, Hours, and Payment, respectively. The first column (width 31, left justified) lists the employee's first and last name, separated by 1 space. The second column (width 5, right justified) lists the total hours worked by this employee for the week. The third column (width 12, right justified) displays the employee's paycheck amount that they are due. All currency values contain a "$", include dollars and cents, and use commas as the thousands separator. o It is possible to provide input to ezpay that will generate numeric values that will not fit into the specified widths for columns 2 and 3 of ezpay's output file. ezpay's behavior is undefined in those situations. o The summary section at the end of the report just sums up the second and third columns. A line of dashes separates the summary line from the list of employees. The formatting remains the same as above for each column. o Possible error messages: "Format Error": The input line cannot be parsed due to incorrect file formatting. This includes field widths being exceeded, incorrect number of fields, improper data types (i.e., supplying a floating point value for an integer values), etc. "Data Error": The input line contains an error in the hourly wage or hours worked per day that violates the numeric specifications above. "Duplicate Error": If any name appears more than once in the input file (in any mixture of lower or upper case letters), then an error message will appear in the output file for each subsequent duplicated employee. The payroll calculation in the output file will use the first instance of the employee from the input file and assume that this first line has the correct data. Note: When an error message occurs, the employee's line will be reproduced at the top of the report, followed by two spaces, followed by the type of the error (in upper case) surrounded by double astericks. (See sample output below). This employee will be left out of the subsequent payroll calculation. o When run in "verbose" mode EZPay will print out a message for each line processed and will end with a summary statement tabulating the number of errors and the number of employees successfully processed. See below for an example. 4. FAULT TOLERANCE o If an input line contains an error, the program will continue to function (by simply appending the error message to the appropriate line in the output file). It should not be the case that an input file causes the program to crash. ============================================================================ Note: sample input and output below ARE part of the specification. ============================================================================ B. Sample Input File and Sample Output File ------------------------------------------- Given the following timesheet file as input: Eric Error -10.00 8 8 8 8 8 Evan Error 10.00 -8 8 8 8 8 Ellen Error 10.00 25 8 8 8 8 Ernie Error 10.00 8.5 8 8 8 8 John Doe 10.00 10 10 10 10 10 Jane Doe 10.00 8 8 8 8 8 Bob Smith 12.00 8 8 8 8 8 Bob Smith 10.00 9 9 9 9 9 Bob Smith 10.00 9 9 9 9 9 EZPay will produce the following output: Eric Error -10.00 8 8 8 8 8 ** DATA ERROR ** Evan Error 10.00 -8 8 8 8 8 ** DATA ERROR ** Ellen Error 10.00 25 8 8 8 8 ** DATA ERROR ** Ernie Error 10.00 8.5 8 8 8 8 ** FORMAT ERROR ** Bob Smith 10.00 9 9 9 9 9 ** DUPLICATE ERROR ** Bob Smith 10.00 9 9 9 9 9 ** DUPLICATE ERROR ** Name Hours Payment Jane Doe 40 $400.00 John Doe 50 $550.00 Bob Smith 40 $480.00 ------------------------------- ----- ------------ Total 130 $1,430.00 C. Sample Output for Verbose Mode --------------------------------- Given the input file from section B above, EZPay will generate the following output if verbose mode has been activated: DATA ERROR : Eric Error -10.00 8 8 8 8 8 DATA ERROR : Evan Error 10.00 -8 8 8 8 8 DATA ERROR : Ellen Error 10.00 25 8 8 8 8 FORMAT ERROR : Ernie Error 10.00 8.5 8 8 8 8 PROCESSING : John Doe PROCESSING : Jane Doe PROCESSING : Bob Smith DUPLICATE ERROR: Bob Smith DUPLICATE ERROR: Bob Smith Total Processed : 3 Data Errors : 3 Format Errors : 1 Duplicate Errors: 2 D. Sample Output for Help Mode --------------------------------- "ezpay --help" produces the following output: Usage: ezpay [-v] [inputfile [outputfile]] Purpose: Calculate payroll for a given timesheet. Options: -v verbose mode Options: inputfile timesheet [default: ezpay.in] Options: outputfile payroll [default: ezpay.out]