PROGRAM-ID. UJIAN.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 MENU PIC 9(1).
01 SISI PIC 9(2).
01 LUAS PIC Z(3).
01 NILAI PIC 9(2).
01 X PIC 9.
01 Y PIC 9.
01 MHS.
02 J PIC 9(2).
02 I PIC 9(2).
02 ANGKA PIC 9(2).
02 NPM PIC A(8) OCCURS 20 TIMES.
02 NAMA PIC A(20) OCCURS 20 TIMES.
02 KELAS PIC A(5) OCCURS 20 TIMES.
SCREEN SECTION.
01 HAPUS.
02 BLANK SCREEN.
PROCEDURE DIVISION.
UTAMA.
DISPLAY (1, 1) '--------MENU--------'.
DISPLAY (2, 1) '1. PERHITUNGAN'.
DISPLAY (3, 1) '2. PERULANGAN '.
DISPLAY (4, 1) '3. ARRAY '.
DISPLAY (5, 1) '4. KELUAR '.
DISPLAY (6, 1) 'MASUKKAN PILIHAN = '.
ACCEPT (6, 20) MENU.
IF MENU = '1'
GO TO A
ELSE IF MENU = '2'
GO TO B
ELSE IF MENU = '3'
GO TO C
ELSE IF MENU = '4'
GO TO D
ELSE DISPLAY HAPUS
GO TO UTAMA.
A.
DISPLAY HAPUS.
DISPLAY (1, 1) 'MASUKKAN SISI PERSEGI = '.
ACCEPT (1, 25) SISI.
COMPUTE LUAS = SISI * SISI.
DISPLAY (2, 1) 'LUAS PERSEGI ADALAH = '
DISPLAY (2, 21) LUAS.
GO TO D.
B.
DISPLAY HAPUS.
DISPLAY ( , ) 'MASUKKAN ANGKA : '.
ACCEPT NILAI.
PERFORM ULANG VARYING X FROM 1 BY 1
UNTIL X > NILAI AFTER Y FROM 1 BY 1 UNTIL Y > X.
GO TO D.
ULANG.
DISPLAY ( , ) Y, ' '.
IF X=Y DISPLAY SPACE.
C.
DISPLAY HAPUS.
DISPLAY (1, 1) 'DATA YANG INGIN DIMASUKKAN : '.
ACCEPT (1, 30) ANGKA.
COMPUTE I = 0.
PERFORM MASUK ANGKA TIMES.
MASUK.
DISPLAY HAPUS.
COMPUTE I = I + 1.
DISPLAY (1, 1) 'DATA KE -', I.
DISPLAY (2, 1) 'MASUKKAN NPM : '.
ACCEPT (2, 20) NPM(I).
DISPLAY (3, 1) 'MASUKKAN NAMA : '.
ACCEPT (3, 20) NAMA(I).
DISPLAY (4, 1) 'MASUKKAN KELAS : '.
ACCEPT (4, 20) KELAS(I).
COMPUTE J = 0.
DISPLAY HAPUS.
PERFORM TAMPIL ANGKA TIMES.
TAMPIL.
DISPLAY NPM(J), ' ', NAMA(J), ' ', KELAS(J).
COMPUTE J = J + 1.
D.
STOP RUN.
Tidak ada komentar:
Posting Komentar