Jumat, 09 November 2012

LA COBOL IV

Program 1 
        IDENTIFICATION DIVISION.
        PROGRAM-ID. TEST.
        AUTHOR. SHIRO.
        ENVIRONMENT DIVISION.
        DATA DIVISION.
        SCREEN SECTION.
        01 CLS.
            02 BLANK SCREEN.
        PROCEDURE DIVISION.
        MULAI.
            DISPLAY CLS.
            PERFORM PROCEDURE-A 3 TIMES.
            PERFORM PROCEDURE-B 5 TIMES.
            PERFORM PROCEDURE-A 3 TIMES.
            PROCEDURE-A.
            DISPLAY '********************'.
            DISPLAY '^^^^^^^^^^^^^^^^^^^^'.
        PROCEDURE-B.
            DISPLAY 'CIUS??? MIAPAH??? MACACIH???'.


Notepad :

Output :

Program 2
    IDENTIFICATION DIVISION.
    PROGRAM-ID. TEST.
    ENVIRONMENT DIVISION.
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    01 DATA1.
        02 NILAI PIC 9(2).
        02 i PIC 9.
        02 j PIC 9.
    SCREEN SECTION.
    01 CLS.
        02 BLANK SCREEN.
    PROCEDURE DIVISION.
    MULAI.
        DISPLAY (, ) 'MASUKAN ANGKA : ' ACCEPT NILAI.
        PERFORM CETAK
        VARYING i FROM 1 BY 1 UNTIL i > NILAI
            AFTER j FROM 1 BY 1 UNTIL j > i.
    SELESAI.
        STOP RUN.
    CETAK.
        DISPLAY (, ) j, ' '.
        IF i = j DISPLAY SPACE.


Notepad :

Output :

Program 3
       IDENTIFICATION DIVISION.
       PROGRAM-ID. TEST.
       AUTHOR. SHIRO.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77 Y PIC 9.
       SCREEN SECTION.
       01 CLS.
           02 BLANK SCREEN.
       PROCEDURE DIVISION.
       MULAI.
           DISPLAY CLS.
           PERFORM TAMPILKAN
         VARYING Y FROM 5 BY -1 UNTIL Y < 1.
           STOP RUN.
       TAMPILKAN.
           DISPLAY (, ) Y , ' '.
 

Notepad :

Output :

Program 4
    IDENTIFICATION DIVISION.
    PROGRAM-ID. TEST.
    ENVIRONMENT DIVISION.
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    01 DATA1.
        02 NILAI PIC 9(2).
        02 i pic 9.
        02 j pic 9.
    SCREEN SECTION.
    01 CLS.
        02 BLANK SCREEN.
    PROCEDURE DIVISION.
    MULAI.
        DISPLAY (, ) 'MASUKAN ANGKA : ' ACCEPT NILAI.
        PERFORM CETAK
        VARYING i FROM nilai BY -1 UNTIL i < 1
            AFTER j FROM 1 BY 1 UNTIL j > i.
    SELESAI.
        STOP RUN.
    CETAK.
        DISPLAY (, ) j, ' '.
        IF i = j DISPLAY SPACE.


Notepad :

Output :

Program 5 : Deret Bilangan Genap
    IDENTIFICATION DIVISION.
    PROGRAM-ID. TEST.
    ENVIRONMENT DIVISION.
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    01 bilangan.
        02 X PIC 99.
        02 Y PIC 99 VALUE 2.
        02 HASIL PIC 99.
        02 SISA PIC 99.
        02 X1 PIC ZZ.
    SCREEN SECTION.
    01 CLS.
        02 BLANK SCREEN.
    PROCEDURE DIVISION.
    MULAI.
          DISPLAY CLS.
          DISPLAY (3, 1) 'Masukan angka : ', ACCEPT X.
          IF x = 0 GO TO k1.
          DIVIDE Y into X GIVING HASIL REMAINDER SISA.
          MOVE X TO X1.
    KONDISI.
         IF SISA = 0
         GO TO JAWAB
         ELSE
         GO TO JAWAB2.
    SELESAI.
         STOP RUN.
    k1.
        MOVE X TO X1.
        DISPLAY 'anda memasukan bilangan KOSONG~'.
        GO TO SELESAI.
    JAWAB.
        MOVE X TO X1.
        DISPLAY (, ) X1 ' '.
        COMPUTE X = X - 1.
        IF x = 0 GO TO SELESAI.
        DIVIDE Y into X GIVING HASIL REMAINDER SISA.
        GO TO KONDISI.
    JAWAB2.
        COMPUTE X = X - 1.
        IF X = 0 GO TO SELESAI.
        DIVIDE Y into X GIVING HASIL REMAINDER SISA.
        GO TO KONDISI.


Notepad :

Output :

Jika anda kesulitan dalam membuat programnya, anda bisa mendownload programnya ~~DISINI~~

0 komentar:

Posting Komentar

 
;