      PROGRAM PGM07
************************************************************************
*    PROGRAMMER: B. Alex Bridges
*    CLASS:      9:00AM
*    PROGRAM:    PGM07.F
*    DUE DATE:   03/04/99
*
* Program Description:
*    This program reads payroll information from a data file. It uses
*    the values to determine the payroll register report for each of
*    the employees.
* Variables:
*    ID      : employee's id
*    DEPSC   : current number of dependents for employee
*    DEPST   : total number of dependents for employees
*    HRATE   : emloyee's hourly rate
*    HOURS   : employee's hours for pay period
*    DEDC    : current deduction for employee
*    DEDT    : total deduction for employees
*    GPAYC   : current gross pay for employee
*    GPAYT   : total gross pay for employees
*    CTYTXC  : current city tax for employee
*    CTYTXT  : total city tax for employees
*    FEDTXC  : current federal tax for employee
*    FEDTXT  : total federal tax for employees
*    NPAYC   : current gross pay for employee
*    NPAYT   : total gross pay for employees
* Input  : ID,DEPSC,HRATE,HOURS
* Output : DEDC,GPAYC,CTYTXC,FEDTXC,NPAYC,DEPST,DEDT,GPAYT,
*          CTYTXT,FEDTXT,NPAYT
************************************************************************

        CHARACTER*11 ID
        REAL DEPSC,DEPST,HRATE,HOURS,DEDC,DEDT,GPAYC,GPAYT,
     1       CTYTXC,CTYTXT,FEDTXC,FEDTXT,NPAYC,NPAYT
        INTEGER I

* open the data file
        OPEN (UNIT=12, FILE="pgm07.dat")

* display the pre-header
        PRINT '(T30,"PAYROLL INPUT DATA",//,
     1          "PROGRAMMER:",T32,"B. Alex Bridges",/,
     2          "DUE DATE:",T32,"03/04/99",/,
     3          "CLASS:",T32,"8:00AM Lab",/,
     4          "DEDUCTION AMOUNT",T32,"$15.00 per dependent",/,
     5          "CITY INCOME TAX (RATE):",T32,"1.15% of Gross",/,
     6          "FEDERAL TAX (RATE):",T32,"20% of Gross minus ",
     c          "deduction",/)'

* display the main header
        PRINT '(T28,"PAYROLL REGISTER REPORT",//,
     1          "CHK",T9,"EMP",T17,"NO.",T25,"DED",T38,"GRS PAY",T50,
     c          "CTY TX",T63,"FED TAX",T72,"NET",/,
     2          "NO.",T9,"ID",T17,"DEPS",T25,"AMT",T38,"AMT",T50,
     c          "AMT",T63,"AMT",T72,"PAY")'

* repeat until end of input file reached
        I = 1
*  => read in values for payroll data items
 10     READ (12, 20, END=30), ID,DEPSC,HRATE,HOURS
 20     FORMAT(A11, F2.0, F4.2, F3.0)

*  => calculate items for payroll
        GPAYC = HRATE * HOURS
        CALL DEDTX(DEPSC,GPAYC,DEDC,CTYTXC,FEDTXC)
        NPAYC = GPAYC - (CTYTXC + FEDTXC)

*  => add current amounts to grand totals
        DEPST = DEPST + DEPSC
        DEDT = DEDT + DEDC
        GPAYT = GPAYT + GPAYC
        CTYTXT = CTYTXT + CTYTXC
        FEDTXT = FEDTXT + FEDTXC
        NPAYT = NPAYT + NPAYC

*  => display the output
        PRINT '(I2,T5,A11,T18,F3.0,T24,F6.2,T35,F8.2,T48,F7.2,T60,F8.2,
     1          T70,F8.2)', I,ID,DEPSC,DEDC,GPAYC,CTYTXC,FEDTXC,NPAYC
        I = I + 1
        GOTO 10

* close the data file, display footer, and print end of program message

 30     CLOSE(12)
        PRINT '(/,"  TOTALS . . . ",T18,F3.0,T24,F6.2,T35,F8.2,T48,F7.2,
     1          T60,F8.2,T70,F8.2)',
     2          DEPST,DEDT,GPAYT,CTYTXT,FEDTXT,NPAYT
        PRINT '(/,T28,"End of program - PGM07.F",/)'

        END

************************************************************************

************************************************************************
* Subroutine: DEDTX                                                    *
* Purpose: Calculates the deductions and taxes.                        *
* Input: --PARAMETERS--                                                *
*        => 'DEPS'  = Number of dependents for employee.               *
*        => 'GPAY'  = Gross pay for the employee.                      *
* Output: --PARAMETERS--                                               *
*        => 'DED'   = Deduction amount.                                *
*        => 'CTYTX' = City tax amount.                                 *
*        => 'FEDTX' = Federal tax amount.                              *
************************************************************************
        SUBROUTINE DEDTX(DEPS,GPAY,DED,CTYTX,FEDTX)
        REAL DEPS,GPAY,DED,CTYTX,FEDTX,TPAY

* calculates deduction amount
        DED = DEPS * 15.00

* calculates taxable amount
        TPAY = GPAY - DED

* calculates federal tax amount
        FEDTX = TPAY * 0.20

* calculates city tax amount
        CTYTX = GPAY * 0.0115

        END
