IDENTIFICATION DIVISION.
PROGRAM-ID. tax_calc.

DATA DIVISION.

WORKING-STORAGE SECTION.

01  TAX-BRACKET         PIC 9V99         VALUE ZEROS.

LINKAGE SECTION.

01  FILING-STATUS       PIC 9 COMP.
        88  FILING-STATUS-SINGLE         VALUE 0.
        88  FILING-STATUS-HEAD-HOUSE     VALUE 1.
        88  FILING-STATUS-MARRIED-JOINT  VALUE 2.
        88  FILING-STATUS-MARRIED-SEP    VALUE 3.
01  TAXABLE-INCOME      USAGE COMP-2.
01  TAXES-OWED          USAGE COMP-2.

PROCEDURE DIVISION USING
    BY REFERENCE FILING-STATUS
    BY REFERENCE TAXABLE-INCOME
    BY REFERENCE TAXES-OWED.

MAIN-PROGRAM.

    PERFORM 1000-GET-TAX-BRACKET THRU 1000-EXIT

    COMPUTE TAXES-OWED = TAXABLE-INCOME * TAX-BRACKET

    MOVE 0 TO RETURN-CODE
    EXIT PROGRAM.


1000-GET-TAX-BRACKET.
    
    IF (FILING-STATUS-SINGLE         AND TAXABLE-INCOME <= 9525)   OR
       (FILING-STATUS-HEAD-HOUSE     AND TAXABLE-INCOME <= 13600)  OR
       (FILING-STATUS-MARRIED-JOINT  AND TAXABLE-INCOME <= 19050)  OR
       (FILING-STATUS-MARRIED-SEP    AND TAXABLE-INCOME <= 9525)
            MOVE .1 TO TAX-BRACKET
            GO TO 1000-EXIT
    END-IF

    IF (FILING-STATUS-SINGLE         AND TAXABLE-INCOME <= 38700)  OR
       (FILING-STATUS-HEAD-HOUSE     AND TAXABLE-INCOME <= 51800)  OR
       (FILING-STATUS-MARRIED-JOINT  AND TAXABLE-INCOME <= 77400)  OR
       (FILING-STATUS-MARRIED-SEP    AND TAXABLE-INCOME <= 38700)
            MOVE .12 TO TAX-BRACKET
            GO TO 1000-EXIT
    END-IF
    
    IF (FILING-STATUS-SINGLE         AND TAXABLE-INCOME <= 82500)  OR
       (FILING-STATUS-HEAD-HOUSE     AND TAXABLE-INCOME <= 82500)  OR
       (FILING-STATUS-MARRIED-JOINT  AND TAXABLE-INCOME <= 165000) OR
       (FILING-STATUS-MARRIED-SEP    AND TAXABLE-INCOME <= 82500)
            MOVE .22 TO TAX-BRACKET
            GO TO 1000-EXIT
    END-IF

    IF (FILING-STATUS-SINGLE         AND TAXABLE-INCOME <= 157500) OR
       (FILING-STATUS-HEAD-HOUSE     AND TAXABLE-INCOME <= 157500) OR
       (FILING-STATUS-MARRIED-JOINT  AND TAXABLE-INCOME <= 315000) OR
       (FILING-STATUS-MARRIED-SEP    AND TAXABLE-INCOME <= 157000)
            MOVE .24 TO TAX-BRACKET
            GO TO 1000-EXIT
    END-IF

    IF (FILING-STATUS-SINGLE         AND TAXABLE-INCOME <= 200000) OR
       (FILING-STATUS-HEAD-HOUSE     AND TAXABLE-INCOME <= 200000) OR
       (FILING-STATUS-MARRIED-JOINT  AND TAXABLE-INCOME <= 400000) OR
       (FILING-STATUS-MARRIED-SEP    AND TAXABLE-INCOME <= 200000)
            MOVE .32 TO TAX-BRACKET
            GO TO 1000-EXIT
    END-IF

    IF (FILING-STATUS-SINGLE         AND TAXABLE-INCOME <= 500000) OR
       (FILING-STATUS-HEAD-HOUSE     AND TAXABLE-INCOME <= 500000) OR
       (FILING-STATUS-MARRIED-JOINT  AND TAXABLE-INCOME <= 600000) OR
       (FILING-STATUS-MARRIED-SEP    AND TAXABLE-INCOME <= 300000)
            MOVE .35 TO TAX-BRACKET
            GO TO 1000-EXIT
    END-IF

    MOVE .37 TO TAX-BRACKET.

1000-EXIT. EXIT.
