Ternyata bahasa pemrograman Cobol itu susah - susah gampang,,,,
Setelah pada penulisan kemarin saya sudah memberikan Program Cobolnya untuk didownload, sekarang saya akan memberi contoh pemrograman Cobol untuk mencari pengurangan matriks....
Ketikkan listing berikut di Cobol anda atau di Notepad dengan penambahan ekstensi .cob di akhir penamaan file (contoh pada notepad, ketika di save ketikkan, misal : matrik.cob)
IDENTIFICATION DIVISION.
PROGRAM-ID. MATRIKS.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 I PIC 9.
77 J PIC 9.
01 CETAK.
02 M1 PIC Z9.
02 M2 PIC Z9.
02 T PIC Z9.
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 99.
01 DATA2.
02 BARIS2 OCCURS 2 TIMES.
03 MATRIK2 OCCURS 2 TIMES PIC 99.
SCREEN SECTION.
01 HAPUS-LAYAR.
02 BLANK SCREEN.
01 TANDA.
02 LINE 3 COLUMN 16 VALUE '-' HIGHLIGHT.
02 LINE 3 COLUMN 31 VALUE '=' HIGHLIGHT.
PROCEDURE DIVISION.
MULAI.
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
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
STOP RUN.
ISI1.
DISPLAY (3, 2) 'MATRIK 1'.
COMPUTE LIN = LIN + 1.
DISPLAY (LIN, 2) 'ELEMEN [', I, ', ', J, '] = '.
ACCEPT MATRIK1 (I, J).
ISI2.
DISPLAY (10, 2) 'MATRIK 2'.
COMPUTE LIN = LIN + 1.
DISPLAY (LIN, 2) 'ELEMEN [', I, ', ', J, '] = '.
ACCEPT MATRIK2 (I, J).
PROSES.
COMPUTE TM (I, J) = MATRIK1 (I, J) - MATRIK2 (I, J).
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, COL + 1) M1.
DISPLAY (LIN, COL + 16) M2.
DISPLAY (LIN, COL + 31) T.
Kalo gak bisa jalan bisa DI DOWNLOAD DIMARI LISTINGANNYA...
ok....
kecil kok filenya......
Setelah pada penulisan kemarin saya sudah memberikan Program Cobolnya untuk didownload, sekarang saya akan memberi contoh pemrograman Cobol untuk mencari pengurangan matriks....
Ketikkan listing berikut di Cobol anda atau di Notepad dengan penambahan ekstensi .cob di akhir penamaan file (contoh pada notepad, ketika di save ketikkan, misal : matrik.cob)
IDENTIFICATION DIVISION.
PROGRAM-ID. MATRIKS.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 I PIC 9.
77 J PIC 9.
01 CETAK.
02 M1 PIC Z9.
02 M2 PIC Z9.
02 T PIC Z9.
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 99.
01 DATA2.
02 BARIS2 OCCURS 2 TIMES.
03 MATRIK2 OCCURS 2 TIMES PIC 99.
SCREEN SECTION.
01 HAPUS-LAYAR.
02 BLANK SCREEN.
01 TANDA.
02 LINE 3 COLUMN 16 VALUE '-' HIGHLIGHT.
02 LINE 3 COLUMN 31 VALUE '=' HIGHLIGHT.
PROCEDURE DIVISION.
MULAI.
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
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
STOP RUN.
ISI1.
DISPLAY (3, 2) 'MATRIK 1'.
COMPUTE LIN = LIN + 1.
DISPLAY (LIN, 2) 'ELEMEN [', I, ', ', J, '] = '.
ACCEPT MATRIK1 (I, J).
ISI2.
DISPLAY (10, 2) 'MATRIK 2'.
COMPUTE LIN = LIN + 1.
DISPLAY (LIN, 2) 'ELEMEN [', I, ', ', J, '] = '.
ACCEPT MATRIK2 (I, J).
PROSES.
COMPUTE TM (I, J) = MATRIK1 (I, J) - MATRIK2 (I, J).
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, COL + 1) M1.
DISPLAY (LIN, COL + 16) M2.
DISPLAY (LIN, COL + 31) T.
Kalo gak bisa jalan bisa DI DOWNLOAD DIMARI LISTINGANNYA...
ok....
kecil kok filenya......
0 komentar:
Posting Komentar