Senin, 14 Desember 2009

Program Cobol Membuat Matriks

     Program Cobol Membuat Matriks


       IDENTIFICATION DIVISION.
       PROGRAM-ID. MAT.
       AUTHOR. DEVIE.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77 I PIC 9.
       77 J PIC 9.
       01 Pilihan.
           02 PIL PIC 9.
       01 TOTAL.
           02 TOTAL-BARIS OCCURS 2 TIMES.
               03 TM OCCURS 2 TIMES PIC 9(3).
       01 MAT1.
           02 BAR1 OCCURS 2 TIMES.
               03 MATRIKA OCCURS 2 TIMES PIC 99.
       01 MAT2.
           02 BAR2 OCCURS 2 TIMES.
               03 MATRIKB OCCURS 2 TIMES PIC 99.
       01 ISI-LAGI PIC X.
           88 LAGI VALUE  "Y", "y".
           88 TIDAK VALUE "T", "t".
       01 CETAK.
           02 M1 PIC Z9.
           02 M2 PIC Z9.
           02 T PIC ZZ9.
       SCREEN SECTION.
       01 HAPUS-LAYAR.
           02 BLANK SCREEN.
       01 TANDA.
           02 LINE 3 COLUMN 15 '+' HIGHLIGHT.
           02 LINE 3 COLUMN 30 '=' HIGHLIGHT.
       01 MENU.
           02 LINE 2 COLUMN 30 "MENU PILIHAN" BACKGROUND-COLOR 4.
       02 LINE 2 COLUMN 30 FOREGROUND-COLOR 5.
           02 LINE 3 COLUMN 30 "============" HIGHLIGHT.
           02 LINE 4 COLUMN 30 "1.Input Matriks".
           02 LINE 5 COLUMN 30 "2.Jumlah Matriks".
           02 LINE 6 COLUMN 30 "============".
           02 LINE 7 COLUMN 30 "3.Keluar".
           02 LINE 8 COLUMN 30 "============".
           02 LINE 9 COLUMN 30 "Pilihan [ ]".
           02 LINE 9 COLUMN 39 PIC 9 TO PIL.
       PROCEDURE DIVISION.
       MULAI.
           DISPLAY HAPUS-LAYAR.
           DISPLAY MENU.
           ACCEPT MENU.
           IF PIL = 1
               PERFORM MULAI-1
           GO TO MULAI
           ELSE
            IF PIL = 2
             PERFORM PROSES
                 VARYING I FROM 1 BY 1 UNTIL I > 2
                    AFTER J FROM 1 BY 1 UNTIL J > 2
         DISPLAY HAPUS-LAYAR
         DISPLAY TANDA
         PERFORM HASIL
                 VARYING I FROM 1 BY 1 UNTIL I > 2
                    AFTER J FROM 1 BY 1 UNTIL J > 2
             COMPUTE LIN = LIN + 2
              

   DISPLAY (10, 5) 'ADA DATA LAGI [Y/T]'
                 ACCEPT ( ,  ) ISI-LAGI
                 IF LAGI GO TO MULAI
         ELSE
                  IF TIDAK GO TO SELESAI
        ELSE
          IF PIL = 3
                  GO TO SELESAI
              ELSE
                  GO TO MULAI.
       SELESAI.
           STOP RUN.
       MULAI-1.
           MOVE 3 TO LIN.
           DISPLAY HAPUS-LAYAR.
           PERFORM ISI1
             VARYING I FROM 1 BY 1 UNTIL I > 2
                 AFTER J FROM 1 BY 1 UNTIL J > 2.
           COMPUTE LIN = 10.
           PERFORM ISI2
             VARYING I FROM 1 BY 1 UNTIL I > 2
                 AFTER J FROM 1 BY 1 UNTIL J > 2.
       ISI1.
           DISPLAY (3, 2) 'MATRIK A'.
           COMPUTE LIN = LIN + 1.
           DISPLAY (LIN, 2) '[', I, ', ', J, '] :'
           ACCEPT MATRIKA (I, J).
       ISI2.
           DISPLAY (10, 2) 'MATRIK B'.
           COMPUTE LIN = LIN + 1.
           DISPLAY (LIN, 2) '[', I, ', ', J, '] :'
           ACCEPT MATRIKB (I, J).
       PROSES.
           COMPUTE TM (I, J) = MATRIKA (I, J) + MATRIKB (I, J).
       HASIL.
           MOVE I TO LIN.
           MOVE J TO COL.
           MOVE MATRIKA (I, J) TO M1.
           MOVE MATRIKB (I, J) TO M2.
           MOVE TM (I, J) TO T.
           COMPUTE LIN = LIN * 2.
           COMPUTE COL = COL * 4.
           DISPLAY (LIN, COL + 1) M1.
           DISPLAY (LIN, COL + 15) M2.
           DISPLAY (LIN, COL + 30) T.
       TANYA.    
       COMPUTE LIN = LIN + 2.
           DISPLAY (LIN, 5) 'ADA DATA LAGI [Y/T]'
           ACCEPT ( ,  ) ISI-LAGI.
           IF LAGI GO TO MULAI.

0 komentar:

Posting Komentar