Program cobol sederhana untuk membuat panjang deret sesuai inputan dan menghitung grade/nilai (A, B, C, D, E)
LISTING PROGRAM :
IDENTIFICATION
DIVISION.
PROGRAM-ID. ERIKA.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 JAWAB PIC X(2).
77 MID PIC 9(3).
77 UAS PIC 9(3).
77 GRADE PIC 9(5).
77 N PIC 9(3).
77 K PIC 9(3).
77 I PIC 9(3).
01 DATA-MHS.
02 NAMA PIC A(20).
02 NPM PIC X(8).
SCREEN SECTION.
01 BERSIH.
02 BLANK SCREEN.
PROCEDURE DIVISION.
MULAI1.
DISPLAY BERSIH.
MULAI2.
DISPLAY (2, 13) 'MENU'.
DISPLAY (4, 5)
'-----------------------'.
DISPLAY (5, 5) '1. PENGURANGAN
DERET'.
DISPLAY (6, 5) '2. HITUNG NILAI'.
DISPLAY (7, 5) '3. KELUAR'.
DISPLAY (8, 5)
'-----------------------'.
DISPLAY (10, 5) 'MASUKKAN PIL : '.
ACCEPT (10, 20) JAWAB.
SELEKSI.
IF JAWAB = 1 GO TO PENGURANGAN.
IF JAWAB = 2 GO TO HITUNG.
IF JAWAB = 3 GO TO KELUAR
ELSE
GO TO MULAI2.
PENGURANGAN.
DISPLAY BERSIH.
DISPLAY (2, 5) 'PANJANG DERET : '.
ACCEPT (2, 20) N.
COMPUTE K = 1.
PERFORM DERET UNTIL N = 0.
DISPLAY (10, 5) 'TEKAN ENTER KEMBALI
KE MENU'.
ACCEPT JAWAB.
GO TO MULAI1.
DERET.
DISPLAY (4, ) '-', K.
COMPUTE K = K + 2.
COMPUTE N = N - 1 .
HITUNG.
DISPLAY BERSIH.
DISPLAY(2, 5) 'NILAI MID = '.
ACCEPT (2, 17) MID.
DISPLAY (3, 5) 'NILAI UAS = '.
ACCEPT (3, 17) UAS.
COMPUTE GRADE = (MID + UAS) / 2.
DISPLAY (4, 5)'GRADE = (MID + UAS ) / 2'.
GO TO SELEKSI2.
SELEKSI2.
DISPLAY (5, 5) 'GRADE = E'.
IF GRADE > 40 DISPLAY (5, 5)
'GRADE = D'
IF GRADE > 60 DISPLAY (5, 5)
'GRADE = C'.
IF GRADE > 70 DISPLAY (5, 5)
'GRADE = B'.
IF GRADE > 85 DISPLAY (5, 5) 'GRADE = A'.
DISPLAY (12, 5) 'TEKAN ENTER KEMBALI
KE MENU'.
ACCEPT JAWAB.
GO TO MULAI1.
KELUAR.
DISPLAY BERSIH.
DISPLAY (2, 5) 'NAMA = '.
ACCEPT (2, 13) NAMA.
DISPLAY (3, 5) 'NPM = '.
ACCEPT (3, 13) NPM.
STOP RUN.
OUTPUT :
No comments:
Post a Comment