Sabtu, 23 Mei 2015

contoh pascal

program datapasienRSKARIADI;

uses crt;

type
  datab = ^data;
  data= record
  nama,png,jk,nk:String;
end;

var
  x,i,a,b,y:integer;
  pasien:array[1..100] of data;


        procedure garis();
            begin
                writeln('________________________________________________________________________________');
            end;


        procedure input();
            begin
               for i:=1 to x do
                 begin
                   with pasien[i] do
                    begin
                      write(i,'.NAMA PASIEN         = ');readln(nama);
                      write(  '  JENIS PENYAKIT      = ');readln(png);
                      write(  '  JENIS KELAMIN       = ');readln(jk);
                      write(  '  NOMOR KAMAR         = ');readln(nk);
                      writeln;
                    end;
                 end;
            end;


        procedure output();
            begin
               garis;
               write('No':3); write('NAMA PASIEN':10); write('JENIS PENYAKIT':20); write('PEMBAYARAN':22); writeln('LAMA DIRUMAH SAKIT':25);
               garis;
                 for a:=1 to x do
                   begin
                     with pasien[a] do
                       begin
                         writeln(a:2,' ':2,nama,' ':3,png:18,jk:21,nk:25);
                       end;
                   end;
               garis;
            end;


        procedure hapus(y:integer);
          var z:integer;
            begin
               if (y > x) or (y < 1)then
                 begin
                   writeln;
                   writeln('pasien dengan no ',y,' tidak tersedia');
                   write('Masukkan nomor pasien yang akan dihapus = ');readln(z);
                   writeln;
                   hapus(z);
                 end

                else
                 begin
                    for b:=y to x do
                       begin
                          if x=1 then
                             begin
                               x:=1;
                             end
                          else
                             pasien[y]:=pasien[y+1];
                       end;

                    x:=x-1;
                    writeln('Data pasien berhasil diHapus');
                    writeln;
                    writeln('Data pasien setelah dihapus');
                    output();
                 end;
            end;



        begin
          clrscr;
            write('Masukkan Jumlah pasien = ');readln(x);
              input();
              output();
            write('Masukkan nomor pasien yang akan dihapus = ');readln(y);
              hapus(y);
          readln;
        end.

Tidak ada komentar:

Posting Komentar