Deductions
Part of the Data and Numbers section of Coddy's COBOL Programming journey. Lesson 22 of 23.
Challenge
EasyTax is 20% of the gross pay and the pension 5%, each rounded to the cent. Declare TAX, PENSION and NET, compute them with net pay as gross minus both, and display the Tax: , Pension: and Net pay: lines.
Example input, one line per ACCEPT: Ada Lovelace, 40, 18.50, 5.
Try it yourself
IDENTIFICATION DIVISION.
PROGRAM-ID. PAYROLL.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 EMP-NAME PIC X(12).
01 HOURS PIC 9(3).
01 RATE PIC 9(4)V99.
01 REG-PAY PIC 9(5)V99.
01 MONEY-OUT PIC $$$,$$9.99.
01 OT-HOURS PIC 9(3).
01 OT-PAY PIC 9(5)V99.
01 GROSS PIC 9(5)V99.
*> Declare TAX, PENSION and NET here
PROCEDURE DIVISION.
ACCEPT EMP-NAME.
ACCEPT HOURS.
ACCEPT RATE.
ACCEPT OT-HOURS.
MULTIPLY HOURS BY RATE GIVING REG-PAY.
COMPUTE OT-PAY ROUNDED = OT-HOURS * RATE * 1.5.
ADD REG-PAY OT-PAY GIVING GROSS.
*> Compute TAX, PENSION and NET here
DISPLAY "Employee: " EMP-NAME.
MOVE REG-PAY TO MONEY-OUT.
DISPLAY "Regular: " MONEY-OUT.
MOVE OT-PAY TO MONEY-OUT.
DISPLAY "Overtime: " MONEY-OUT.
MOVE GROSS TO MONEY-OUT.
DISPLAY "Gross: " MONEY-OUT.
*> Display the Tax, Pension and Net pay lines
STOP RUN.