-->

MEMBUAT PROGRAM FILE MAHASISWA DENGAN PASCAL

Berikut merupakan program FILE MAHASISWA dengan PASCAL :



uses crt;
const
garis ='======================================================';

type Mahasiswa = record
  nama: string[25];
  npm: string[8];
  kelas: string[5];
  end;
type
  tipelarik= string[25];
  larikurut=array[1..100] of tipelarik;

var
file_mhs : file of Mahasiswa;
filemhs : Mahasiswa;
i,j, jumlah_data : integer;
lagi : char;
temp: string[5];
pil : integer;
gabung : larikurut;
gabung1 : larikurut;



procedure input;
begin
assign (file_mhs, 'Mhs.txt') ;
rewrite (file_mhs);
i := 0;
repeat
inc(i);
clrscr;
writeln('Mengisi data pada file "Mhs.txt"....');
writeln('------------------------------------');
writeln('Mengisi Data ke-', i);
writeln;
with filemhs do
begin
write('Nama Mahasiswa     : ');Readln(nama);
write('NPM Mahasiswa      : '); readln(npm);
write('Kelas              : '); readln(kelas);
end;
write(file_mhs,filemhs);
writeln;
write('Akan Mengisi Lagi [Y/T] : '); readln(lagi);
until Not (lagi In ['Y','y']);
close(file_mhs);
end;


procedure sortir(x:larikurut; bawah,atas :word);
var i,j :word;
sementara :tipelarik;
begin
                while atas>bawah do
                begin
                i:=bawah;
                j:=atas;
                sementara:=x[bawah];
                while i<j do
                begin
                    WHILE x[j]>sementara Do
             J:=J-1;
                     x[i]:=x[j];
             while(i<j) and (x[i]<=sementara) do
             i:=i+1;
                     x[j]:=x[i];
                     end;
                     x[i]:=sementara;
        sortir(x,bawah,i-1);
        bawah:=i+1;
        end;
        end;



procedure cetak;
begin
assign(file_mhs,'Mhs.txt');
reset(file_mhs);
clrscr;
jumlah_data := FileSize (file_mhs);
writeln(' ':20,'Daftar Absensi Mahasiswa Gunadarma');
writeln(' ':20,'==================================');
writeln; writeln (garis);
writeln('| no |      Nama Mahasiswa        | NPM      | Kelas |');
writeln (garis);
for i:= 1 to jumlah_data do
begin
read(file_mhs,filemhs);
gotoxy (1,wherey); write('| ',i:2,' |');
with filemhs Do
begin
gotoxy (8,wherey); writeln ( filemhs.nama);
gotoxy (35,wherey); write('| ', filemhs.npm);
gotoxy(46,wherey); write('| ',filemhs.kelas,'    |');
end;
writeln;
end;
writeln(garis);
readln;
close(file_mhs);
end;

procedure tampilsortir;
label empat;
var
gabung,gabung1,name,npms,class:larikurut;
i,J:integer;temp:STRING[5];
begin
clrscr;
assign(file_mhs,'Mhs.txt');
reset(file_mhs);
for i := 1 to filesize(file_mhs) do
begin
seek(file_mhs, i-1);
read (file_mhs,filemhs);
name[i] := filemhs.nama;
class[i] := filemhs.kelas;
npms[i] := filemhs.npm;
gabung[i] := concat(name[i],npms[i],class[i]);
gabung1[i] := concat(class[i], name[i], npms[i]);
end;


j := 2;
sortir(gabung1,1,filesize(file_mhs));
write('kelas : '); readln (temp);
if length(temp) <> 5 then
begin
clrscr;
gotoxy(28,100);
writeln('Kelas tidak ditemukan<ulangi[y/t]>');
clrscr;
writeln('Kelas :', temp);
writeln('daftar mahasiswa');
goto empat;
end;


clrscr;
empat:
writeln (garis);
writeln ('| no |      Nama Mahasiswa        | NPM      | Kelas |');
writeln (garis);
for i:= 1 to filesize(file_mhs) do
begin
if (name[i]<> ' ') then begin

writeln('| ', i:2,'| ', copy(gabung[i],18,8),'    ', copy(gabung[i],0,5),'   ', copy(gabung[i],6,12)); end;
end;
j:=I+10;
end;

procedure tambahdata;
begin
     assign(file_mhs,'Mhs.txt');
     reset(file_mhs);
                 if IOresult <> 0 then rewrite(file_mhs);
                 seek(file_mhs,filesize(file_mhs));
lagi := 'Y';
while upcase(lagi)='Y' do
begin
     clrscr;
     with filemhs do
     begin
     gotoxy(5,5);write('-----------------------------------------------------');
     gotoxy(5,6);write('|nama mahasiswa    :                               |');
     gotoxy(5,7);write('|npm mahasiswa      :                               |');
     gotoxy(5,8);write('|kelas mahasiswa     :                               |');
     gotoxy(5,9);write('-----------------------------------------------------');
     gotoxy(27,6);readln(kelas);
     gotoxy(27,7);readln(npm);
     gotoxy(27,8);readln(nama);
     end;
     write(file_mhs, filemhs);
     gotoxy(5,15);write('anda ingin memasukkan data lagi(Y/T)?');readln(lagi);
     end;
     close(file_mhs);
   end;

begin
repeat
clrscr;
writeln ('    Menu    ');
writeln ('1. Input data');
writeln ('2. Sort data');
writeln ('3. output data');
writeln ('4. Update data');
writeln ('5. keluar');
write ('Masukkan pilihan : '); readln(pil);
case pil of
1 : input;
2 : tampilsortir;
3 : cetak;
4 : tambahdata
end;
until pil = 5;
end.


output :















HALAMAN SELANJUTNYA:

0 Response to "MEMBUAT PROGRAM FILE MAHASISWA DENGAN PASCAL "

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel

PEMBERITAHUAN...!!!!!

Untuk Berlangganan Artikel Terbaru !!

Website ini pindah ke Website :.
IKAMPUS.MY.ID