IDENTIFICATION DIVISION.
PROGRAM-ID. ARRAY2.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-SUBSCRIPT.
02 SUBSCRIPT-CABANG PIC 9.
02 SUBSCRIPT-BULAN PIC 9.
01 TABEL-PENJUALAN-MOBIL.
02 CABANG OCCURS 4 TIMES.
03 BULAN OCCURS 3 TIMES.
04 JUMLAH-UNIT-TERJUAL PIC 99.
77 TOTAL-PENJUALAN-CABANG PIC 99 VALUE 0.
SCREEN SECTION.
01 CLS.
02 BLANK SCREEN.
PROCEDURE DIVISION.
PROGRAM-UTAMA.
PERFORM ENTRY-TABEL.
PERFORM TAMPILKAN-TABEL.
STOP RUN.
ENTRY-TABEL.
DISPLAY 'PEMASUKKAN DATA KE DALAM ARRAY DIMENSI DUA:'.
PERFORM ISI-DATA-TABEL
VARYING SUBSCRIPT-CABANG FROM 1 BY 1 UNTIL SUBSCRIPT-CABANG > 4
AFTER SUBSCRIPT-BULAN FROM 1 BY 1 UNTIL SUBSCRIPT-BULAN > 3.
ISI-DATA-TABEL.
DISPLAY ( , ) 'CABANG ', SUBSCRIPT-CABANG, 'BULAN ', SUBSCRIPT-BULAN, ' : '.
ACCEPT ( , ) JUMLAH-UNIT-TERJUAL (SUBSCRIPT-CABANG, SUBSCRIPT-BULAN).
DISPLAY SPACE.
TAMPILKAN-TABEL.
DISPLAY CLS.
DISPLAY 'MENAMPILKAN ISI TABEL BERDIMENSI DUA : '.
PERFORM DISPLAY-DATA-TABEL
VARYING SUBSCRIPT-CABANG FROM 1 BY 1 UNTIL SUBSCRIPT-CABANG > 4
AFTER SUBSCRIPT-BULAN FROM 1 BY 1 UNTIL SUBSCRIPT-BULAN > 3.
DISPLAY-DATA-TABEL.
DISPLAY ( , ) 'CABANG ', SUBSCRIPT-CABANG, 'BULAN ', SUBSCRIPT-BULAN, ' : ',JUMLAH-UNIT-TERJUAL (SUBSCRIPT-CABANG,SUBSCRIPT-BULAN).
DISPLAY SPACE.
ADD JUMLAH-UNIT-TERJUAL (SUBSCRIPT-CABANG, SUBSCRIPT-BULAN) TO TOTAL-PENJUALAN-CABANG.
IF (SUBSCRIPT-BULAN - 3)
DISPLAY '**** TOTAL PENJUALAN PER CABANG - ', TOTAL-PENJUALAN-CABANG.
MOVE 0 TO TOTAL-PENJUALAN-CABANG.
Tidak ada komentar:
Posting Komentar