File Random
Program File Random untuk data mahasiswa dengan menggunakan bahasa pemrograman QBasic
Program :
10 CLS
20 LOCATE 5, 33: PRINT " MENU UTAMA"
30 LOCATE 6, 28: PRINT "*************************"
40 LOCATE 8, 33: PRINT "1. INPUT DATA"
60 LOCATE 9, 33: PRINT "2. OUTPUT"
70 LOCATE 10, 33: PRINT "3. EXIT"
75 LOCATE 11, 28: PRINT "*************************"
80 LOCATE 12, 33: INPUT "MASUKKAN PILIHAN: ", X
SELECT CASE X
CASE 1:
CLS
L$ = "Y": B$ = "t": I = O
OPEN "R", #1, "H:MHS.TXT", 28
FIELD #1, 8 AS NPM$, 15 AS NM$, 5 AS KLS$
WHILE L$ = "y" OR L$ = "Y": I = I + 1: B$ = "T"
LOCATE 3, 10: PRINT "MASUKKAN DATA"
LOCATE 4, 10: PRINT "_____________________________"
LOCATE 6, 5: PRINT "DATA KE :", I
WHILE B$ = "T" OR B$ = "t"
LOCATE 7, 5: INPUT "NPM:", NPMI$
LOCATE 8, 5: INPUT "NAMA:", NMI$
LOCATE 9, 5: INPUT "KELAS:", KLSI$
LOCATE 11, 5: INPUT "DATA SUDAH BENAR [Y/T]?", B$
WEND
LSET NPM$ = NPMI$: LSET NM$ = NMI$
LSET KLS$ = KLSI$
PUT #1, I
LOCATE 13, 5: INPUT "MASIH ADA DATA LAGI[Y/T]?", L$
CLS
WEND
CLOSE (1)
GOTO 20
END
CASE 2:
CLS
GR$ = STRING$(43, "-"): I = 1: NO = 0: HAL = 1
OPEN "R", #1, "H:MHS.TXT", 28
FIELD #1, 8 AS NPM$, 15 AS NM$, 5 AS KLS$
100 LOCATE 5, 5: PRINT "DAFTAR NAMA MAHASISWA"
LOCATE 6, 5: PRINT "HALAMAN : ", HAL
LOCATE 6, 5: PRINT "-------------------------------------------"
LOCATE 7, 5: PRINT "NPM NAMA KELAS"
LOCATE 8, 5: PRINT "-------------------------------------------"
110 GET #1, I
IF EOF(1) THEN 260
NO = NO + 1
LOCATE 9, 5: PRINT NPM$, NM$, KLS$: I = I + 1
IF NO = 20 THEN 200
GOTO 110
200 PRINT TAB(5); GR$
HAL = HAL + 1: NO = 0
PRINT "TEKAN ENTER UNTUK KE HALAMAN BERIKUTNYA", INPUT$(1)
GOTO 100
260 PRINT TAB(5); GR$
CLOSE #1
END
CASE 3:
CLS
PRINT "TEKAN ENTER UNTUK KELUAR"
END
CASE ELSE:
PRINT "MAAF ANGKA YANG ANDA MASUKKAN SALAH"
END SELECT
END
Output
Apabila memilih selain pilihan diatas, misalnya 5 maka outputnya
Program :
10 CLS
20 LOCATE 5, 33: PRINT " MENU UTAMA"
30 LOCATE 6, 28: PRINT "*************************"
40 LOCATE 8, 33: PRINT "1. INPUT DATA"
60 LOCATE 9, 33: PRINT "2. OUTPUT"
70 LOCATE 10, 33: PRINT "3. EXIT"
75 LOCATE 11, 28: PRINT "*************************"
80 LOCATE 12, 33: INPUT "MASUKKAN PILIHAN: ", X
SELECT CASE X
CASE 1:
CLS
L$ = "Y": B$ = "t": I = O
OPEN "R", #1, "H:MHS.TXT", 28
FIELD #1, 8 AS NPM$, 15 AS NM$, 5 AS KLS$
WHILE L$ = "y" OR L$ = "Y": I = I + 1: B$ = "T"
LOCATE 3, 10: PRINT "MASUKKAN DATA"
LOCATE 4, 10: PRINT "_____________________________"
LOCATE 6, 5: PRINT "DATA KE :", I
WHILE B$ = "T" OR B$ = "t"
LOCATE 7, 5: INPUT "NPM:", NPMI$
LOCATE 8, 5: INPUT "NAMA:", NMI$
LOCATE 9, 5: INPUT "KELAS:", KLSI$
LOCATE 11, 5: INPUT "DATA SUDAH BENAR [Y/T]?", B$
WEND
LSET NPM$ = NPMI$: LSET NM$ = NMI$
LSET KLS$ = KLSI$
PUT #1, I
LOCATE 13, 5: INPUT "MASIH ADA DATA LAGI[Y/T]?", L$
CLS
WEND
CLOSE (1)
GOTO 20
END
CASE 2:
CLS
GR$ = STRING$(43, "-"): I = 1: NO = 0: HAL = 1
OPEN "R", #1, "H:MHS.TXT", 28
FIELD #1, 8 AS NPM$, 15 AS NM$, 5 AS KLS$
100 LOCATE 5, 5: PRINT "DAFTAR NAMA MAHASISWA"
LOCATE 6, 5: PRINT "HALAMAN : ", HAL
LOCATE 6, 5: PRINT "-------------------------------------------"
LOCATE 7, 5: PRINT "NPM NAMA KELAS"
LOCATE 8, 5: PRINT "-------------------------------------------"
110 GET #1, I
IF EOF(1) THEN 260
NO = NO + 1
LOCATE 9, 5: PRINT NPM$, NM$, KLS$: I = I + 1
IF NO = 20 THEN 200
GOTO 110
200 PRINT TAB(5); GR$
HAL = HAL + 1: NO = 0
PRINT "TEKAN ENTER UNTUK KE HALAMAN BERIKUTNYA", INPUT$(1)
GOTO 100
260 PRINT TAB(5); GR$
CLOSE #1
END
CASE 3:
CLS
PRINT "TEKAN ENTER UNTUK KELUAR"
END
CASE ELSE:
PRINT "MAAF ANGKA YANG ANDA MASUKKAN SALAH"
END SELECT
END
Output
Apabila memilih selain pilihan diatas, misalnya 5 maka outputnya
Komentar
Posting Komentar