Program Data Mahasiswa Sederhana November 21, 2009
Program Data Mahasiswa Sederhana Dah lama nich gak bagi – bagi program pascal lagi. Kali ini aku bakal share program mahasiswa sederhana dalam pascal. Dalam program ini kita bisa melakukan inputan, kita juga bisa melakukan pengurutan berdasarkan NRP, Nama, dan Nilai menggunakan metode Bubble Short, kita juga bisa meng update isi dari data kita mulai dari update NRP, Nama, dan Nilai, di dalam program ini juga terdapat metode searching yaitu menggunakan metode sequential search berdasarkan NRP. Hm….. sederhana sich….. tapi program ini bisa dibilang cukup komplit. Heheheheh……. Ok lah kalo begitu….. here we go….. Source Code Program Mahasiswa; uses wincrt; label 1; type DaMa = record NRP : String; Nama : String; Nilai : Integer; end; var List : array [1..10] of DaMa; i, h, j, n, pil, m : integer; NRP1 : String; temp : DaMa; procedure insert; begin inc(i); inc(n); gotoxy(6,16); write('Masukkan Data Mahasiswa'); gotoxy(6,18); write('NRP Mahasiswa : '); readln(List[i].NRP); gotoxy(6,19); write('Nama Mahasiswa : '); readln(List[i].Nama); gotoxy(6,20); write('Nilai Mahasiswa : '); readln(List[i].Nilai); end; procedure cari(z : String); var k : integer; ketemu : boolean; begin k := 1;
1
By Lukman Wahyudi ( apocalypsezone.blogspot.com )
Program Data Mahasiswa Sederhana November 21, 2009 ketemu := false; while (not ketemu) and (k <= n) do if List[k].NRP = z then ketemu := true else k := k + 1; if ketemu then begin gotoxy(21,15); write('Mahasiswa Dengan NRP ',z,' : Ditemukan'); gotoxy(18,17); writeln('|¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯|'); gotoxy(18,18); writeln('| NRP | NAMA | NILAI |'); gotoxy(18,19); writeln('|___________|____________________|_________|'); gotoxy(18,20); writeln('| | | |'); gotoxy(18,21); writeln('| | | |'); gotoxy(20,21); writeln(List[k].NRP); gotoxy(33,21); writeln(List[k].Nama); gotoxy(55,21); writeln(List[k].Nilai); gotoxy(18,22); writeln('|___________|____________________|_________|'); end else begin gotoxy(20,15); write('Mahasiswa Dengan NRP ',z,' : Tidak Ditemukan'); end; end; procedure update(p : String); var x, y : String; z, q, o : integer; ketemu : boolean; begin q := 1; if (NRP1 = '0') or (NRP1 = '') then begin gotoxy(15,20); write('Masukkan NRP yang Benar'); readkey; end else begin ketemu := false; while (not ketemu) and (q <= n) do if List[q].NRP = p then ketemu := true else q := q + 1; if ketemu then
2
By Lukman Wahyudi ( apocalypsezone.blogspot.com )
Program Data Mahasiswa Sederhana November 21, 2009 begin gotoxy(5,21); write('Data Yang Akan di Update : '); gotoxy(5,20); write('1. NRP 2. Nama 3. Nilai'); gotoxy(33,21); readln(pil); case pil of 1 : begin gotoxy(5,23); write('Masukkan NRP yang Baru : '); readln(x); List[q].NRP := x; end; 2 : begin gotoxy(5,23); write('Masukkan Nama yang Baru : '); readln(y); List[q].Nama := y; end; 3 : begin gotoxy(5,23); write('Masukkan Nilai yang Baru : '); readln(z); List[q].Nilai := z; end; end; end else begin gotoxy(5,22); write('NRP ',p,' Tidak Terdapat Dalam Daftar'); readkey; end; end; end; procedure cetak; begin if m = 2 then begin gotoxy(37,2); write('Tabel Nilai Mahasiswa Setelah Diurutkan'); end else if m = 0 then begin gotoxy(47,2); write('Tabel Nilai Mahasiswa'); end; gotoxy(35,4); writeln('|¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯|'); gotoxy(35,5); writeln('| NRP | NAMA | NILAI |'); gotoxy(35,6); writeln('|___________|____________________|_________|'); gotoxy(35,7); writeln('| | | |'); gotoxy(35,8+n); writeln('|___________|____________________|_________|'); for j := 1 to n do begin
3
By Lukman Wahyudi ( apocalypsezone.blogspot.com )
Program Data Mahasiswa Sederhana November 21, 2009 gotoxy(35,7+j); writeln('| | gotoxy(37,7+j); writeln(List[j].NRP); gotoxy(50,7+j); writeln(List[j].Nama); gotoxy(72,7+j); writeln(List[j].Nilai); end;
|
|');
end; begin { Program Utama } i := 0; n := 0; repeat 1 : clrscr; m := 0; gotoxy(3,2); writeln('|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|'); gotoxy(3,3); writeln('| Menu |'); gotoxy(3,4); writeln('| |'); gotoxy(3,5); writeln('|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|'); gotoxy(3,6); writeln('| 1. Insert |'); gotoxy(3,7); writeln('| 2. Urutkan |'); gotoxy(3,8); writeln('| 3. Cari MHS |'); gotoxy(3,9); writeln('| 4. Update |'); gotoxy(3,10); writeln('| 5. Exit |'); gotoxy(3,11); writeln('| |'); gotoxy(3,12); writeln('|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|'); gotoxy(3,13); writeln('| Pilihan : |'); gotoxy(3,14); writeln('|_______________|'); gotoxy(12,25); write('created by : Lukman Wahyudi ( apocalypsezone.blogspot.com )'); cetak; gotoxy(16,13); readln(pil); case pil of 1 : begin m := 0; insert; end; 2 : begin repeat clrscr; gotoxy(3,2); writeln('|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|'); gotoxy(3,3); writeln('| Menu |'); gotoxy(3,4); writeln('| |'); gotoxy(3,5); writeln('|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|'); gotoxy(3,6); writeln('| 1. NRP |'); gotoxy(3,7); writeln('| 2. Nama |'); gotoxy(3,8); writeln('| 3. Nilai |'); gotoxy(3,9); writeln('| 4. Menu |'); gotoxy(3,10); writeln('| 5. Exit |'); gotoxy(3,11); writeln('| |');
4
By Lukman Wahyudi ( apocalypsezone.blogspot.com )
Program Data Mahasiswa Sederhana November 21, 2009 gotoxy(3,12); writeln('|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|'); gotoxy(3,13); writeln('| Pilihan : |'); gotoxy(3,14); writeln('|_______________|'); gotoxy(12,25); write('created by : Lukman Wahyudi ( apocalypsezone.blogspot.com )'); cetak; gotoxy(16,13); readln(pil); m := 2; case pil of 1 : begin for h := 1 to n-1 do for j := 1 to n-1 do if List[j].NRP > List[j+1].NRP then begin temp := List[j]; List[j] := List[j+1]; List[j+1] := temp; end; end; 2 : begin for h := 1 to n-1 do for j := 1 to n-1 do if List[j].Nama > List[j+1].Nama then begin temp := List[j]; List[j] := List[j+1]; List[j+1] := temp; end; end; 3 : begin for h := 1 to n-1 do for j := 1 to n-1 do if List[j].Nilai > List[j+1].Nilai then begin temp := List[j]; List[j] := List[j+1]; List[j+1] := temp; end; end; 4 : begin goto 1; end; end; cetak; until pil >= 5; end;
5
By Lukman Wahyudi ( apocalypsezone.blogspot.com )
Program Data Mahasiswa Sederhana November 21, 2009 3 : begin gotoxy(21,15); write('NRP Mahasiswa yang akan dicari : '); readln(NRP1); cari(NRP1); gotoxy(18,24); write('Tekan Sembarang Tombol Untuk Kembali Ke Menu'); readkey; end; 4 : begin gotoxy(5,18); write('NRP Mahasiswa Yang Akan di Update : '); readln(NRP1); update(NRP1); end; end; until pil >= 5; end.
6
By Lukman Wahyudi ( apocalypsezone.blogspot.com )
Program Data Mahasiswa Sederhana November 21, 2009
Runing Program
Gambar 1. Masukkan Data
Gambar 2. Mengurutkan Data
7
By Lukman Wahyudi ( apocalypsezone.blogspot.com )
Program Data Mahasiswa Sederhana November 21, 2009
Gambar 3. Searching Data
Gambar 4. Update Data
8
By Lukman Wahyudi ( apocalypsezone.blogspot.com )