// Bill McQuain // 999-99-9999 // 10.28.1998 // // Design outline for the payroll program using array variables: Begin Main program: // Major variables housed in Main: IdNum[] list of employee ID numbers Age[] list of employee ages NumEmp number of employees GrossPay[] list of employee gross pay amounts NetPay[] list of employee net pay amounts SSI[] list of employee SS taxes FIT[] list of employee income taxes InsFee[] list of employee insurance fees InsPlan[] list of employee insurance plan codes I. Read employee data from input file: ReadData() II. Calculate employee withholding data and net pay: CalcData() III. Print the table of employee information: PrintTable() End Main program. ////////////////////////////////////////////////////////////////////// // The function ReadData reads employee data from the input file and // stores it in the array parameters. ReadData will read until the // end of the input file or until the arrays are filled (determined // by the global constant MaxEmp). // // Parameters: // // IdNum[] list of employee ID numbers // GrossPay[] list of gross pay amounts // Age[] list of employee ages // InsPlan[] list of insurance plan codes // NumEmp number of employees for whom data was stored // Begin ReadData: I. Open input file to "inpay.dat" II. Read first line of data from input file (priming read): A. Read: id number, age, gross pay, and insurance plan code // Process and read next line until there's no more data or // we've filled up the arrays: III. While there's more data and the arrays aren't full Do A. Store the values just read into the appropriate array cells. B. Read the next line of input data. C. Count this employee Endwhile III. Set NumEmp equal to employee count IV. Close input file. End ReadData. ///////////////////////////////////////////////////////////////////// // CalcData is used to calculate the net pay amounts for all // employees. // // Parameters: // // GrossPay[] list of gross pay amounts // Age[] list of employee ages // InsPlan[] list of insurance plan codes // NumEmp number of employees to be processed // InsFee[] list of insurance fees // FIT[] list of federal income taxes // SSI[] list of social security taxes // NetPay[] list of net pay amounts // Begin CalcData: ////////////////////////////////////////////////////////////// // Calculate the insurance fee, income tax, social security // tax and net pay for each employee, storing the results in // the relevant arrays: // I. For each employee: A. Calculate insurance fee: Insurance() B. Calculate FIT: FedTax() C. Calculate SSI: SSI rate times gross pay D. Calculate NetPay: gross pay - FIT - SSI - insurance fee End CalcData. ///////////////////////////////////////////////////////////////////// // Insurance is used to calculate the proper insurance fee for an // employee. // // Parameters: // // InsPlan character 'B' or 'D', indicating plan selected // Age employee's age // // Return value: // // InsFee insurance fee charged to employee // Begin Insurance: I. If Plan B is selected If age is in low bracket InsFee is low Plan B rate Else if age is in middle bracket InsFee is middle Plan B rate Else InsFee is high Plan B rate Endif Else If age is in low bracket InsFee is low Plan D rate Else if age is in middle bracket InsFee is middle Plan D rate Else InsFee is high Plan D rate Endif Endif II. Return InsFee End Insurance. ///////////////////////////////////////////////////////////////////// // FedTax is used to calculate the proper income tax for an employee. // // Parameter: // // GrossPay employee's gross pay amount // // Return value: // // FIT income tax withheld for employee // Begin FedTax: I. If income is in high bracket Calculate FIT using high rate Else If income is in middle bracket Calculate FIT using middle rate Else Calculate FIT using low rate Endif II. Return FIT End FedTax. ///////////////////////////////////////////////////////////////////// // PrintHeader is used to print header for output file. // // Parameter: // // outPay output file stream variable // Begin PrintHeader: I. Print programmer's name II. Print output title III. Print blank line IV. Print column labels V. Print table delimiters End PrintHeader. ///////////////////////////////////////////////////////////////////// // PrintTable is used to print the table of employee data to output // file. // // Parameters: // // IdNum[] list of id numbers of employees // GrossPay[] list of gross pay for employees // InsFee[] list of insurance fees for employees // FIT[] list of income taxes for employees // SSI[] list of social security taxes for employees // NetPay[] list of net pay for employees // NumEmp number of employees to print data for // Begin PrintTable: I. Open output file "outpay.dat" II. Print output header: PrintHeader() // Print the table, line by line: III. For each employee: A. print id number B. print gross pay C. print insurance fee D. print FIT E. print SSI F. print net pay IV. Calculate and print averages: CalcAvgs() V. Close the output file. End PrintTable. ///////////////////////////////////////////////////////////////////// // CalcAvgs is used to print final averages to input file. // // Parameters: // // outPay output file stream variable // Gross[] list of gross pay amounts // InsFee[] list of insurance fees // FIT[] list of income tax // SSI[] list of social security tax // NetPay[] list of net pay // NumEmployees number of employees // Begin CalcAvgs: I. Initalize all the running totals to zero: TotalGross, TotalNet, TotalIns, TotalSSI, TotalFIT II. Print out footer for table: // If NumEmp > 0 then calculate totals and print out averages; // otherwise print zeros for the averages. // III. If NumEmp is greater than 0 A. Calculate the totals of gross pay, insurance fees, FIT, SSI, and net pay amounts. B. Print each total divided by NumEmp. Else C. Print zeros for the averages. Endif End CalcAvgs.