Saturday, 1 March 2014

COBOL Program to Calculate Simple and Compound interest using COMPUTE verb



COBOL Program to Calculate Simple and Compound interest using COMPUTE verb

PROGRAM:  
       IDENTIFICATION DIVISION.
       PROGRAM-ID  SCINTR.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
           77 P PIC 9(4).
           77 N PIC 9(4).
           77 R PIC 9(4).
           77 SI PIC 9999.99.
           77 CO PIC 9999.99.
           77 I PIC 9999.99.
           77 I1 PIC 9999.99.
       PROCEDURE DIVISION.
       MAIN-PARA.
           DISPLAY " ENTER P VALUE" .
           ACCEPT P.
           DISPLAY " ENTER N VALUE ".
           ACCEPT N.
           DISPLAY " ENTER R VALUE ".
           ACCEPT R.
           DISPLAY "PRINCIPLE AMOUNT = ", P.
           DISPLAY "NO OF YEARS = ", N .
           DISPLAY  "RATE OF INTREST = ", R.
           COMPUTE SI = P + (  (P * N * R) / 100 ).
            DISPLAY " SIMPLE INTREST IS ", SI.
           COMPUTE CO = P * ( 1 + ( R / 100) ) ** N.
           DISPLAY " COMPOUND INTREST IS ", CO. 
           STOP RUN.

No comments: