monggo langsung simak saja listingan beserta outputnya , semoga bermanfaat ya :))
Listing program menu matriks pada cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. MATRIKS-KALI.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 I PIC 9.
77 J PIC 9.
01 PIL PIC 9.
01 ULANG PIC A.
88 YA VALUE 'Y', 'y'.
88 TIDAK VALUE 'T', 't'.
01 CETAK.
02 M1 PIC Z9.
02 M2 PIC Z9.
02 MTT1 PIC Z9.
02 MTT2 PIC Z9.
02 T PIC ZZ9.
02 T1 PIC ZZ9.
02 T2 PIC ZZ9.
01 TOTAL.
02 TOTAL-BARIS OCCURS 2 TIMES.
03 TM OCCURS 2 TIMES PIC 999.
01 DATA1.
02 BARIS1 OCCURS 2 TIMES.
03 MATRIK1 OCCURS 2 TIMES PIC 999.
01 DATA2.
02 BARIS2 OCCURS 2 TIMES.
03 MATRIK2 OCCURS 2 TIMES PIC 99.
01 DATAT1.
02 BARIS1 OCCURS 2 TIMES.
03 MT1 OCCURS 2 TIMES PIC 999.
01 DATAT2.
02 BARIS2 OCCURS 2 TIMES.
03 MT2 OCCURS 2 TIMES PIC 99.
SCREEN SECTION.
01 HAPUS-LAYAR.
02 BLANK SCREEN.
01 TANDAT.
02 LINE 4 COLUMN 16 VALUE '+' HIGHLIGHT.
02 LINE 4 COLUMN 31 VALUE '=' HIGHLIGHT.
01 TANDAK.
02 LINE 4 COLUMN 16 VALUE '-' HIGHLIGHT.
02 LINE 4 COLUMN 31 VALUE '=' HIGHLIGHT.
01 TANDAX.
02 LINE 4 COLUMN 16 VALUE '*' HIGHLIGHT.
02 LINE 4 COLUMN 31 VALUE '=' HIGHLIGHT.
01 TANDATR.
02 LINE 4 COLUMN 17 VALUE '=' HIGHLIGHT.
02 LINE 10 COLUMN 17 VALUE '=' HIGHLIGHT.
PROCEDURE DIVISION.
MENU.
MOVE 3 TO LIN.
DISPLAY HAPUS-LAYAR.
DISPLAY '================='.
DISPLAY '= MENU MATRIKS ='.
DISPLAY '================='.
DISPLAY '=1. INPUT ='.
DISPLAY '=2. PENJUMLAHAN ='.
DISPLAY '=3. PENGURANGAN ='.
DISPLAY '=4. PERKALIAN ='.
DISPLAY '=5. TRANSPOSE ='.
DISPLAY '=6. EXIT ='.
DISPLAY '================='.
DISPLAY ' '.
DISPLAY 'PILIHAN KAMUH : '.
ACCEPT PIL.
GO TO MEN1, MEN2, MEN3, MEN4, MEN5, MEN6 DEPENDING ON PIL.
DISPLAY 'ERROR BOS'.
GO TO MENU.
MEN1.
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
DISPLAY ' '.
DISPLAY ' '.
DISPLAY 'DATA SUDAH TERINPUT ^-^'.
GO TO MEN7.
MEN2.
PERFORM TAMBAH
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
DISPLAY HAPUS-LAYAR.
DISPLAY ( 1 , 15 ) 'MATRIK A + MATRIK B'.
DISPLAY TANDAT.
PERFORM HASIL
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
GO TO MEN7.
MEN3.
PERFORM KURANG
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
DISPLAY HAPUS-LAYAR.
DISPLAY ( 1 , 15 ) 'MATRIK A - MATRIK B'.
DISPLAY TANDAK.
PERFORM HASIL
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
GO TO MEN7.
MEN4.
PERFORM KALI
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
DISPLAY HAPUS-LAYAR.
DISPLAY ( 1 , 15 ) 'MATRIK A * MATRIK B'.
DISPLAY TANDAX.
PERFORM HASIL
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2.
GO TO MEN7.
MEN5.
PERFORM TRANSPOSE
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2
DISPLAY HAPUS-LAYAR.
DISPLAY ( 1 , 15 ) 'HASIL TRANSPOSE MATRIKS A & B'.
DISPLAY TANDATR.
PERFORM HASILT
VARYING I FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2.
GO TO MEN7.
MEN6.
DISPLAY ' '.
DISPLAY 'TERIMA KASIH ^_^'.
STOP RUN.
MEN7.
DISPLAY ' '.
DISPLAY ' '.
DISPLAY ' '.
DISPLAY ' '.
DISPLAY 'KEMBALI KE MENU ? [Y/T]'.
ACCEPT ULANG.
IF YA GO TO MENU.
STOP RUN.
ISI1.
DISPLAY ( 3 , 2 ) 'MATRIK A'.
COMPUTE LIN = LIN + 1.
DISPLAY ( LIN , 2 ) 'ELEMEN [', I, ', ', J, '] = '.
ACCEPT MATRIK1 ( I , J ).
ISI2.
DISPLAY ( 10 , 2 ) 'MATRIK B'.
COMPUTE LIN = LIN + 1.
DISPLAY ( LIN , 2 ) 'ELEMEN [', I, ', ', J, '] = '.
ACCEPT MATRIK2 ( I , J ).
TAMBAH.
COMPUTE TM (I, J) = MATRIK1 (I, J) + MATRIK2 (I, J).
KURANG.
COMPUTE TM (I, J) = MATRIK1 (I, J) - MATRIK2 (I, J).
KALI.
COMPUTE TM ( 1 , 1 ) = MATRIK1 ( 1 , 1 ) * MATRIK2 ( 1 , 1 )
+ MATRIK1 ( 1 , 2 ) * MATRIK2 ( 2 , 1 ).
COMPUTE TM ( 1 , 2 ) = MATRIK1 ( 1 , 1 ) * MATRIK2 ( 1 , 2 )
+ MATRIK1 ( 1 , 2 ) * MATRIK2 ( 2 , 2 ).
COMPUTE TM ( 2 , 1 ) = MATRIK1 ( 2 , 1 ) * MATRIK2 ( 1 , 1 )
+ MATRIK1 ( 2 , 2 ) * MATRIK2 ( 2 , 1 ).
COMPUTE TM ( 2 , 2 ) = MATRIK1 ( 2 , 1 ) * MATRIK2 ( 1 , 2 )
+ MATRIK1 ( 2 , 2 ) * MATRIK2 ( 2 , 2 ).
TRANSPOSE.
MOVE MATRIK1 ( 1, 1 ) TO MT1 ( 1, 1 ).
MOVE MATRIK1 ( 1, 2 ) TO MT1 ( 2, 1 ).
MOVE MATRIK1 ( 2, 1 ) TO MT1 ( 1, 2 ).
MOVE MATRIK1 ( 2, 2 ) TO MT1 ( 2, 2 ).
MOVE MATRIK2 ( 1, 1 ) TO MT2 ( 1, 1 ).
MOVE MATRIK2 ( 1, 2 ) TO MT2 ( 2, 1 ).
MOVE MATRIK2 ( 2, 1 ) TO MT2 ( 1, 2 ).
MOVE MATRIK2 ( 2, 2 ) TO MT2 ( 2, 2 ).
HASIL.
MOVE I TO LIN.
MOVE J TO COL.
MOVE MATRIK1 ( I , J ) TO M1.
MOVE MATRIK2 ( I , J ) TO M2.
MOVE TM ( I , J ) TO T.
COMPUTE LIN = LIN * 2.
COMPUTE COL = COL * 4.
DISPLAY ( LIN + 1 , COL + 1 ) M1.
DISPLAY ( LIN + 1, COL + 16 ) M2.
DISPLAY ( LIN + 1, COL + 30 ) T.
HASILT.
MOVE I TO LIN.
MOVE J TO COL.
MOVE MATRIK1 ( I , J ) TO T1.
MOVE MATRIK2 ( I , J ) TO T2.
MOVE MT1 ( I, J ) TO MTT1.
MOVE MT2 ( I, J ) TO MTT2.
COMPUTE LIN = LIN * 2.
COMPUTE COL = COL * 4.
DISPLAY ( LIN + 1 , COL + 3 ) T1.
DISPLAY ( LIN + 1 , COL + 16 ) MTT1.
DISPLAY ( LIN + 7 , COL + 3 ) T2.
DISPLAY ( LIN + 7 , COL + 16 ) MTT2.
MENU MATRIKS
INPUTAN
PERTAMBAHAN MATRIKS
PENGURANGAN MATRIKS
TRANSPOSE
EXIT
0 komentar:
Posting Komentar