Penggunaan Procedure Pada Pascal

program pro;
uses crt;

var
   tothg,hrgs,dis,hrg,jmlpj,pj,hrgp,hrgd: real;
   jum,pil: integer;
   ulang: boolean;
   lagi: char;
   kdbr: string[10];
   nmbrg: string[25];

procedure hitungtotalharga;
begin
     tothg:=jum*hrgs;
end;

procedure hitungdiskon;
begin
     dis:=dis/100*tothg;
     hrgd:=tothg-dis;
end;

procedure hitungpajak;
begin
     jmlpj:=pj/100*tothg;
     hrgp:=tothg+jmlpj;
end;

{Program Utama}

begin
     ulang:=true;
     while ulang do
     begin
          clrscr;
          writeln('Menu Utama');
          writeln;
          writeln('1. Hitung Total Harga');
          writeln('2. Hitung Diskon');
          writeln('3. Hitung Pajak Total Harga');
          writeln('4. Selesai');
          writeln;
          write('Pilih : -');readln(pil);

          case pil of
               1:begin
                      lagi:='Y';
                      while upcase(lagi)='Y' do
                      begin
                           clrscr;
                           writeln('Isi Data Barang');
                           writeln;
                           write('Kode Barang   :');readln(kdbr);
                           write('Nama Barang   :');readln(nmbrg);
                           write('Jumlah        :');readln(jum);
                           write('Harga Satuan  :');readln(hrgs);
                           hitungtotalharga;
                           writeln('Total Harga :',tothg:12:2);
                           writeln;
                           write('Isi Lagi (Y/T) :');readln(lagi);
                      end;
               end;
               2:begin
                      lagi:='Y';
                      while upcase(lagi)='Y' do
                      begin
                           clrscr;
                           writeln('Hitung Harga Setelah Diskon');
                           writeln;
                           write('Kode Barang   :');readln(kdbr);
                           write('Nama Barang   :');readln(nmbrg);
                           write('Jumlah        :');readln(jum);
                           write('Harga Satuan  :');readln(hrgs);
                           write('Diskon        :');readln(dis);
                           hitungtotalharga;
                           writeln('Total Harga :',tothg:12:2);
                           hitungdiskon;
                           writeln('Harga Bersih :',hrgd:12:2);
                           writeln;
                           write('Isi Lagi (Y/T) :');readln(lagi);
                      end;
               end;
               3:begin
                      lagi:='Y';
                      while upcase(lagi)='Y' do
                      begin
                           clrscr;
                           writeln('Hitung Harga Setelah Pajak');
                           writeln;
                           write('Kode Barang   :');readln(kdbr);
                           write('Nama Barang   :');readln(nmbrg);
                           write('Jumlah        :');readln(jum);
                           write('Harga Satuan  :');readln(hrgs);
                           write('Pajak %       :');readln(pj);
                           hitungtotalharga;
                           writeln('Total Harga :',tothg:12:2);
                           hitungpajak;
                           writeln('Harga Bersih :',hrgp:12:2);
                           writeln;
                           write('Isi Lagi (Y/T) :');readln(lagi);
                      end;
               end;
               4:exit;
          end;{case}
     end;{while ulang}
end.

Comments

Popular posts from this blog

Cara Optimalkan PES 2013 Pada PC Spek Rendah

Serial Key Windows XP Profesional SP 2

ID Flexi Wifi.id Februari 2015