Menu
CoddyTech

Monthly Interest

Part of the Decisions and Loops section of Coddy's COBOL Programming journey. Lesson 17 of 20.

challenge icon

Challenge

Easy

A loan schedule starts with one month of interest. Write CALC-INTEREST: INTEREST is BALANCE * RATE / 1200, ROUNDED to the cent, where RATE is the yearly percent. For 1000 at 12 the program prints Interest:    10.00.

Example input, one line per ACCEPT: 1000, 12.

Try it yourself

       IDENTIFICATION DIVISION.
       PROGRAM-ID. LOAN.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 AMOUNT PIC 9(5).
       01 RATE PIC 99.
       01 BALANCE PIC 9(6)V99.
       01 INTEREST PIC 9(4)V99.
       01 OUT-INT PIC Z,ZZ9.99.
       PROCEDURE DIVISION.
       MAIN-PARA.
           ACCEPT AMOUNT.
           ACCEPT RATE.
           MOVE AMOUNT TO BALANCE.
           PERFORM CALC-INTEREST.
           MOVE INTEREST TO OUT-INT.
           DISPLAY "Interest: " OUT-INT.
           STOP RUN.
       CALC-INTEREST.
           *> Compute INTEREST from BALANCE and RATE

All lessons in Decisions and Loops