- Nama : Program Biodata Mahasiswa ILKOM
- Bahasa : Pascal
- Software : Free Pascal IDE
- Deskripsi : Program ini terdiri dari 3 bagian, yaitu input, output, dan sorting. Pada bagian input, user diminta untuk menginputkan nama, nim, umur, dan semester. Pada bagian output, program menampilkan data yang telah diinputkan dalam bentuk tabel. Dan yang terakhir adalah sorting yang terdiri dari sorting berdasarkan nim, umur, dan semester.
- Screenshoot : >> klik di sini <<
- Source Code :
program biodata_mhs;
uses crt; type rec_data =record nama :string; nim :string; umur :byte; smt :byte; end; tp_data =array[1..100] of rec_data; var data :tp_data; n,m :byte; pilihan :char; procedure input; begin repeat clrscr; inc(n); gotoxy(25,1); write('>> Input Data <<'); gotoxy(20,3); write('Data ke-',n); gotoxy(22,4); write('Nama : ');readln(data[n].nama); gotoxy(22,5); write('NIM : ');readln(data[n].nim); gotoxy(22,6); write('Umur : ');readln(data[n].umur); gotoxy(22,7); write('Semester : ');readln(data[n].smt); repeat gotoxy(20,9); write('Input Lagi? [Y/T]');pilihan:=upcase(readkey); until (pilihan='Y') or (pilihan='T'); until pilihan='T'; end; procedure output; begin clrscr; gotoxy(25,1); write('>> Biodata Mahasiswa ILKOM <<');
gotoxy(8,3);
write('=================================================
===============');
gotoxy(8,4); write('| No | Nama | NIM |
Umur | Semester |');
gotoxy(8,5); write('|----|---------------------------|-----------|---
---|----------|');
for m:=1 to n do begin gotoxy(8,5+m); write('| | |
|
| |');
gotoxy(10,5+m);write(m:2); gotoxy(15,5+m);write(data[m].nama); gotoxy(43,5+m);write(data[m].nim); gotoxy(56,5+m);write(data[m].umur:2); gotoxy(65,5+m);write(data[m].smt:2); end; gotoxy(8,6+n); write('===============================================
=================');
readkey; end; procedure swap_s(var i,j:string); var k:string; begin k:=i; i:=j; j:=k; end; procedure swap_b(var i,j:byte); var k:byte; begin k:=i; i:=j; j:=k; end; procedure sort_nim(c:byte;a:tp_data;var b:tp_data); var x,y:byte; begin for x:=c downto 2 do for y:=1 to x-1 do if a[y].nim>a[y+1].nim then begin swap_s(a[y].nama,a[y+1].nama); swap_s(a[y].nim, a[y+1].nim); swap_b(a[y].umur,a[y+1].umur); swap_b(a[y].smt, a[y+1].smt); end; b:=a; end; procedure sort_umur(c:byte;a:tp_data;var b:tp_data); var x,y:byte; begin for x:=c downto 2 do for y:=1 to x-1 do if a[y].umur>a[y+1].umur then begin swap_s(a[y].nama,a[y+1].nama); swap_s(a[y].nim, a[y+1].nim); swap_b(a[y].umur,a[y+1].umur); swap_b(a[y].smt, a[y+1].smt); end; b:=a; end; procedure sort_smt(c:byte;a:tp_data;var b:tp_data); var x,y:byte; begin for x:=c downto 2 do for y:=1 to x-1 do if a[y].smt>a[y+1].smt then begin swap_s(a[y].nama,a[y+1].nama); swap_s(a[y].nim, a[y+1].nim); swap_b(a[y].umur,a[y+1].umur); swap_b(a[y].smt, a[y+1].smt); end; b:=a; end; begin repeat clrscr; gotoxy(34,1); write('>> Menu <<'); gotoxy(30,3); write('[1] Input Data'); gotoxy(30,4); write('[2] Lihat Data'); gotoxy(30,5); write('[3] Sorting NIM'); gotoxy(30,6); write('[4] Sorting Umur'); gotoxy(30,7); write('[5] Sorting Semester'); gotoxy(30,8); write('[0] Keluar'); gotoxy(30,10);write('Pilihan : ');pilihan:=readkey; case pilihan of '1':input; '2':output; '3':begin sort_nim(n,data,data); gotoxy(30,12);write('Sorting NIM selesai ...'); readkey; end; '4':begin sort_umur(n,data,data); gotoxy(30,12);write('Sorting umur selesai ...'); readkey; end; '5':begin sort_smt(n,data,data); gotoxy(30,12);write('Sorting semester selesai ...'); readkey; end; '0':; end; until pilihan='0'; end. |
0 komentar:
Posting Komentar