program BuatArsipMahsiswa;
uses wincrt;
type DataMhs = Record
NPM : longint;
Nama : string [25];
IP : real;
end;
Var Msiswa : dataMhs;
Mhs : file of dataMhs;
begin
assign (Mhs,'data.dat');
rewrite(Mhs);
write('NPM : ');readln(Msiswa.NPM);
while(Msiswa.NPM < 999999999) do
begin
write('Nama : ');readln(Msiswa.Nama);
write('IP : ');readln(Msiswa.IP);
write(Mhs,Msiswa);
write('NPM : ');readln(Msiswa.NPM);
end;
close(Mhs);
end.
program BacaArsipMahasiswa;
uses wincrt;
type DataMhs = record
NPM : longint;
Nama : string [25];
Ip : real;
end;
var Msiswa : DataMhs;
Mhs : file of DataMhs;
begin
assign(Mhs,'data.dat');
reset(Mhs);
while not EOF(Mhs)do
begin
read(Mhs,Msiswa);
writeln('NPM :',Msiswa.NPM);
writeln('Nama :',Msiswa.Nama);
writeln('IP :',Msiswa.IP:0:2);
end;
close(Mhs);
end.
program CariArsipMahasiswa;
uses wincrt;
type DataMhs = record
NPM : longint;
Nama : string [25];
IP : real;
end;
var Msiswa,RekMhs : DataMhs;
Mhs : file of DataMhs;
ketemu : boolean;
nomor : integer;
begin
write('Masukkan NPM yang akan dicari : ');readln(nomor);
assign(Mhs,'data.dat');
reset(Mhs);
ketemu := false;
while(not EOF(Mhs))and(not ketemu)do
begin
read(Mhs,RekMhs);
if RekMhs.NPM = Nomor then
ketemu :=true;
end;
if(ketemu)then
write(nomor,'ditemukan')
else
write(nomor,'tidak ditemukan');
close(Mhs);
end.
Post a Comment