Menu
CoddyTech

Overtime

Part of the Data and Numbers section of Coddy's COBOL Programming journey. Lesson 21 of 23.

challenge icon

Challenge

Easy

Overtime hours are paid at one and a half times the rate. Declare OT-HOURS, OT-PAY and GROSS, read OT-HOURS after the rate, compute OT-PAY rounded to the cent and GROSS as the sum of both pays, and display the Overtime: and Gross:     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.
       *> Declare OT-HOURS, OT-PAY and GROSS here
       PROCEDURE DIVISION.
           ACCEPT EMP-NAME.
           ACCEPT HOURS.
           ACCEPT RATE.
           *> Read OT-HOURS here
           MULTIPLY HOURS BY RATE GIVING REG-PAY.
           *> Compute OT-PAY and GROSS here
           DISPLAY "Employee: " EMP-NAME.
           MOVE REG-PAY TO MONEY-OUT.
           DISPLAY "Regular:  " MONEY-OUT.
           *> Display the Overtime and Gross lines
           STOP RUN.

All lessons in Data and Numbers