Program Antrian Linked List

program antrianlinkedlist;
uses crt;
type pointer1=^antrian;
                pointer2=^formulir;
                pointer3=^seleksi;
 antrian=record
                no_antri:byte;
                bel1:pointer1;
                end;
formulir=record
                nomor,umur:byte;
                nama,alamat,riwayat:string;
                pil1,pil2,pil3:integer;
                bel2:pointer2;
                end;
seleksi=record
                nomor,umur:byte;
                nama,alamat,riwayat,ket:string;
                pil1,pil2,pil3:integer;
                bel3:pointer3;
                end;

var n,m,s,pil,no_ant:byte;
                awal1,akhir1:pointer1;
                awal2,akhir2:pointer2;
                awal3,akhir3:pointer3;

function habis(x:byte):boolean;
begin
if x=20 then habis:=true else habis:=false;
end;

procedure masuk_ant(var x:pointer1);
var baru:pointer1;
begin
writeln('Antrian pembelian formulir PNS');
inc(no_ant);
writeln('Anda mendapat antrian nomor ',no_ant);
new(baru);
baru^.no_antri:=no_ant;
baru^.bel1:=nil;
if awal1=nil then
begin
awal1:=baru;
x:=baru;
end
else begin
                x^.bel1:=baru;
                x:=baru;
end;
writeln('Pengantri baru telah masuk antrian');
end;


procedure cetak_ant(var x:pointer1);
var bantu:pointer1;
begin
n:=0;
writeln('Daftar Pengantri Saat Ini');
writeln('+============================+');
writeln('| Posisi |   Nomor Antrian   |');
writeln('|========|===================|');
new(bantu);bantu:=x;
while bantu<>nil do
begin
inc(n);
writeln('|',n:4,'    | ',bantu^.no_antri:8,'          |');
bantu:=bantu^.bel1;
end;
writeln('+========+===================+');
writeln;
writeln(n,' Pengantri');
end;

procedure seleksi_pns(var x:pointer2;var y:pointer3);
var isi:byte;
                bantu:pointer2;
                baru:pointer3;
                ada:boolean;
                jml:integer;
               
                label balik,balik1,balik2;
begin
jml:=0;
ada:=false;
writeln('Mengisi formulir Pendaftaran PNS');
write('Masukkan nomor formulir yang akan diisi : ');readln(isi);
new(bantu);
bantu:=x;
while bantu>nil do
begin
                if bantu^.nomor=isi then
                begin
                new(baru);
                if baru^.pil1<0 then writeln('Data telah di isi') else 
                begin
                                                ada:=true;
                                                inc(s);
                                                baru^.nama:=bantu^.nama;
                                                baru^.nomor:=bantu^.nomor;
                                                baru^.alamat:=bantu^.alamat;
                                                baru^.umur:=bantu^.umur;
                                                writeln('Akan Mengisi nilai Tes Peserta =  ',baru^.nama);
                                                balik:
                                                write('Masukkan nilai Tes Wawasan Kebangsaan <max=300> : ');readln(baru^.pil1);
                                                if baru^.pil1>300 then begin writeln('Nilai Maximal 300 Ulangi '); goto balik; end;
                                                balik1:
                                                write('Masukkan nilai Tes Intelegensi Umum <max=100> : ');readln(baru^.pil2);
                                                if baru^.pil2>100 then begin writeln('Nilai Maximal 100 Ulangi '); goto balik1; end;
                                                balik2:
                                                write('Masukkan nilai Tes Karakteristik Pribadi  <max=100> : ');readln(baru^.pil3);           
                                                if baru^.pil3>100 then begin writeln('Nilai Maximal 100 Ulangi '); goto balik2; end;            
                                                jml:=jml+(baru^.pil1+baru^.pil2+baru^.pil3);
                                               
                if jml<400 then
                baru^.ket:='Gagal'
                else baru^.ket:='Lulus';
                                                if awal3=nil then
                                                begin
                                                                awal3:=baru;
                                                                y:=baru;
                                                end
                                                else
                                                 begin
                                                                y^.bel3:=baru;
                                                                y:=baru;
                                                 end;
                end;
                end;
                bantu:=bantu^.bel2;
end;
if not ada then writeln('Nomor formulir ',isi ,' tidak terdapat') else writeln('Anda telah selesai mengisi formulir');
end;


procedure cetak_pendaftar(var x:pointer2);
var bantu:pointer2;
begin
writeln('Berikut adalah Daftar Hasil Seleksi PNS ');
writeln('|===============================================================|');
writeln('|Nomor    Nama         Riwayat Pendidikan    Umur    Alamat     |');
writeln('|===============================================================|');
new(bantu);
bantu:=x;
while bantu<>nil do
begin
                writeln('|',bantu^.nomor:3,' ',bantu^.nama:10,'  ',bantu^.riwayat:18,'   ',bantu^.umur:10,'   ',bantu^.alamat:8,'     |');
                bantu:=bantu^.bel2;
end;
writeln('|===============================================================|');
writeln('Saat ini terdapat  ',m,' Pendaftar');
end;


procedure cetak_hasil(var y:pointer3);
var bantu:pointer3;
begin

writeln('Berikut adalah Daftar Hasil Seleksi PNS ');
writeln('Nilai Yang Lulus Harus Sama atau di atas 400  ');
writeln('|===============================================================|');
writeln('|Nomor     Nama     TWK       TIU     TKP     Keterangan        |');
writeln('|===============================================================|');
new(bantu);
bantu:=y;
while bantu<>nil do
begin
                writeln('| ',bantu^.nomor:2,' ',bantu^.nama:10,'  ',bantu^.pil1:6,'   ',bantu^.pil2:6,'   ',bantu^.pil3:6,' ',bantu^.ket:13,'         |');
                bantu:=bantu^.bel3;
end;
writeln('|===============================================================|');
writeln('Sebanyak  ',s,' Peserta Telah mengikuti Seleksi');
end;



procedure header;
begin
writeln('Pendidikan terakhir ');
writeln('1. SMA/Sedrajat');
writeln('2. Diploma 3');
writeln('3. Sarjan S1');
end;
procedure daftar_form(var x:pointer1;var y:pointer2);
var baru:pointer2;
pili:byte;
label ulang;
begin
writeln('Layanan pembelian formulir PNS');
writeln('Selamat datang nomor Antrian ',x^.no_antri);
x:=X^.bel1;
inc(m);
new(baru);
baru^.nomor:=m;
write('Masukan Nama  Anda               : ');readln(baru^.nama);
ulang:
write('Masukan Umur Anda  <Min 18th>    : ');readln(baru^.umur);
if baru^.umur<18 then begin writeln('Umur Minimal 18 th Ulangi ');goto ulang;  end;
write('Masukan Alamat Anda              : ');readln(baru^.alamat);
header;
write('Masukan Pendidikan Terakhir Anda : ');readln(pili);
if pili=1 then
baru^.riwayat:='SMA/Sedrajat'
 else if pili=2 then
 baru^.riwayat:='Diploma 3' else
 baru^.riwayat:='Sarjana S1';
baru^.bel2:=nil;
if awal2=nil then
begin
                awal2:=baru;
                y:=baru;
end
else
 begin
                y^.bel2:=baru;
                y:=baru;
 end;
 writeln('Pendaftaran telah di lakukan');
end;

begin
new(awal1);new(akhir1);
new(awal2);new(akhir2);
new(awal3);new(akhir3);
n:=0;
m:=0;
no_ant:=0;
awal1:=nil;akhir1:=nil;
awal2:=nil;akhir2:=nil;
awal3:=nil;akhir3:=nil;
repeat
                clrscr;
                writeln('+=============================+');
                writeln('|      Pengelolaan PNS        |');
                writeln('|=============================|');
                writeln('|1.| Masuk Antrian            |');
                writeln('|2.| Pendaftaran Formulir PNS |');
                writeln('|3.| Cetak Pendaftar PNS      |');
                writeln('|4.| Seleksi PNS              |');
                writeln('|5.| Tampil                   |');
                writeln('|6.| Cetak Antrian            |');
                writeln('|0.| Selesai                  |');
                writeln('+=============================+');
                write('Pilihan anda 0-6 >> ');readln(pil);

                case pil of
                1:if habis(m) then writeln('Formulir Sudah habis') else masuk_ant(akhir1);
                2:if awal1=nil then writeln('Tidak ada pengantri yang akan membeli formulir') else daftar_form(awal1,akhir2);
                3:if awal2=nil then writeln('Belum ada formulir yang di beli') else cetak_pendaftar(awal2);
                4:if awal2=nil then writeln('Belum ada formulir yang terjual') else seleksi_pns(awal2,akhir3);
                5:if awal2=nil then writeln('Belum ada formulir yang di beli') else cetak_hasil(awal3);
                6:if awal1=nil then writeln('Pengantri kosong') else cetak_ant(awal1);
                0:writeln('Terima kasih ') else writeln('Anda salah memilih menu ');

end;
readln;
until pil=0;


end.



Silakan diterapkan di rumah masing masing

Share on Google Plus

About R Farisy

0 komentar:

Catat Ulasan