Contoh Program Menu Sederhana Menggunakan Qbasic

Kali ini saya akan sharing source code program menu sederhana dengan menggunakan QBasic. Secara umum program ini menggunakan perintah SELECT...CASE sebagai navigasi pilihan menu, dan implementasi perintah LOCATE untuk mengatur lokasi berdasarkan koordinat x, y. Serta perintah COLOR untuk mengatur warna. Langsung saja berikut source codenya :

100 CLS
DIM pil AS INTEGER
LOCATE 5, 20
COLOR 3
PRINT "--------------------------"
LOCATE 6, 20
COLOR 3
PRINT "          MENU            "
LOCATE 7, 20
COLOR 3
PRINT "--------------------------"
LOCATE 8, 20
COLOR 4
PRINT "    1. DISKON"
LOCATE 9, 20
COLOR 5
PRINT "    2. BIODATA"
LOCATE 10, 20
COLOR 6
PRINT "    3. NILAI AKHIR"
LOCATE 11, 20
COLOR 8
PRINT "    4. EXIT       "
LOCATE 12, 20
COLOR 3
PRINT "--------------------------"
LOCATE 13, 25
COLOR 2
INPUT "PILIHAN "; pil

SELECT CASE pil
CASE IS = 1
200 CLS
        LOCATE 9, 20
        COLOR 4
        INPUT "Masukkan Harga(Rp) ", hrg
        CLS
        LOCATE 9, 20
        COLOR 4
        INPUT "Masukkan Diskon(%) ", dis
        korting = dis / 100 * hrg
        hrgakhir = hrg - korting
        CLS
        LOCATE 9, 20
        COLOR 4
        PRINT "CALCULATING."
        SLEEP 1
        LOCATE 9, 20
        COLOR 4
        PRINT "CALCULATING.."
        SLEEP 1
        LOCATE 9, 20
        COLOR 4
        PRINT "CALCULATING..."
        SLEEP 1
        CLS
        LOCATE 5, 20
        COLOR 4
        PRINT "-----------------------------------------"
        LOCATE 6, 20
        COLOR 4
        PRINT "            PROGRAM DISKON "
        LOCATE 7, 20
        COLOR 4
        PRINT "-----------------------------------------"
        LOCATE 8, 20
        COLOR 4
        PRINT " HARGA AWAL              = Rp "; hrg
        LOCATE 9, 20
        COLOR 4
        PRINT " BESAR DISKON            = "; dis; "%"
        LOCATE 10, 20
        COLOR 4
        PRINT " HARGA SETELAH DISKON    = Rp "; hrgakhir
        LOCATE 11, 20
        COLOR 4
        PRINT "-----------------------------------------"
        LOCATE 12, 24
        COLOR 2
        PRINT "            1. HITUNG LAGI"
        LOCATE 13, 24
        COLOR 2
        PRINT "            2. BACK TO MENU"
        LOCATE 14, 24
        COLOR 2
        INPUT "             PILIHAN "; pil
        SELECT CASE pil
        CASE IS = 1
        GOTO 200
        CASE IS = 2
        GOTO 100
        CASE ELSE
        LOCATE 15, 24
        COLOR 2
        PRINT "PILIHAN SALAH, BACK TO MENU"
        GOTO 100
        END SELECT
CASE IS = 2
300 CLS
        LOCATE 9, 20
        COLOR 5
        INPUT "Masukkan Nama "; nama$
        CLS
        LOCATE 9, 20
        COLOR 5
        INPUT "Masukkan Kelas "; kelas$
        CLS
        LOCATE 9, 20
        COLOR 5
        INPUT "Masukkan Universitas "; univ$
        CLS
        LOCATE 9, 20
        COLOR 5
        PRINT "NOW LOADING."
        SLEEP 1
        LOCATE 9, 20
        COLOR 5
        PRINT "NOW LOADING.."
        SLEEP 1
        LOCATE 9, 20
        COLOR 5
        PRINT "NOW LOADING..."
        SLEEP 1
        CLS
        LOCATE 4, 20
        COLOR 5
        PRINT "---------------------------"
        LOCATE 5, 20
        COLOR 5
        PRINT "       BIODATA ANDA        "
        LOCATE 6, 20
        COLOR 5
        PRINT "---------------------------"
        LOCATE 7, 20
        COLOR 5
        PRINT "NAMA        : "; nama$
        LOCATE 8, 20
        COLOR 5
        PRINT "KELAS       : "; kelas$
        LOCATE 9, 20
        COLOR 5
        PRINT "UNIVERSITAS : "; univ$
        LOCATE 10, 20
        COLOR 5
        PRINT "---------------------------"
        LOCATE 11, 24
        COLOR 2
        PRINT "1. INPUT LAGI"
        LOCATE 12, 24
        COLOR 2
        PRINT "2. BACK TO MENU"
        LOCATE 13, 24
        COLOR 2
        INPUT "PILIHAN "; pil
        SELECT CASE pil
        CASE IS = 1
        GOTO 300
        CASE IS = 2
        GOTO 100
        CASE ELSE
        LOCATE 13, 24
        COLOR 5
        PRINT "PILIHAN SALAH, BACK TO MENU"
        GOTO 100
        END SELECT
CASE IS = 3
400 CLS
        LOCATE 9, 20
        COLOR 6
        INPUT "Masukkan Nilai UTS "; uts
        CLS
        LOCATE 9, 20
        COLOR 6
        INPUT "Masukkan Nilai UAS "; uas
        CLS
        nilai = (.7 * uts) + (.3 * uas)
        LOCATE 9, 24
        COLOR 6
        PRINT "PROCESSING."
        SLEEP 1
        LOCATE 9, 24
        COLOR 6
        PRINT "PROCESSING.."
        SLEEP 1
        LOCATE 9, 24
        COLOR 6
        PRINT "PROCESSING..."
        SLEEP 1
        CLS
        LOCATE 4, 20
        COLOR 6
        PRINT "-----------------------------"
        LOCATE 5, 20
        COLOR 6
        PRINT "     PROGRAM NILAI AKHIR     "
        LOCATE 6, 20
        COLOR 6
        PRINT "-----------------------------"
        LOCATE 7, 20
        COLOR 6
        PRINT " Nilai UTS   : "; uts
        LOCATE 8, 20
        COLOR 6
        PRINT " Nilai UAS   : "; uas
        LOCATE 9, 20
        COLOR 6
        PRINT " Nilai Akhir : "; nilai
        LOCATE 10, 20
        COLOR 6
        PRINT "-----------------------------"
        LOCATE 11, 24
        COLOR 2
        PRINT "1. HITUNG LAGI"
        LOCATE 12, 24
        COLOR 2
        PRINT "2. BACK TO MENU"
        LOCATE 13, 24
        COLOR 2
        INPUT "PILIHAN "; pil
        SELECT CASE pil
        CASE IS = 1
        GOTO 400
        CASE IS = 2
        GOTO 100
        CASE ELSE
        LOCATE 13, 24
        COLOR 6
        PRINT "PILIHAN SALAH, BACK TO MENU"
        GOTO 100
        END SELECT
CASE IS = 4
500 CLS
        LOCATE 9, 30
        COLOR 8
        PRINT "CLOSING PROGRAM."
        SLEEP 1
        LOCATE 9, 30
        COLOR 8
        PRINT "CLOSING PROGRAM.."
        SLEEP 1
        LOCATE 9, 30
        COLOR 8
        PRINT "CLOSING PROGRAM..."
        SLEEP 2
        CLS
        LOCATE 9, 30
        COLOR 8
        PRINT "THANK YOU"
        GOTO 600
CASE ELSE
GOTO 600
END SELECT
600 END


Setelah di-compile hasilnya adalah sebagai berikut :


Sumber :

http://fajar-surya.blogspot.co.id/2014/09/contoh-program-menu-sederhana.html








Komentar

Postingan populer dari blog ini

C++ (Program Kalkulator Sederhana)

Sistem Informasi Perbankan

Logika Orde Pertama (First-Order Logic)