Function Pada Pascal

program func_3;
uses crt;

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

function tothg : real;
begin
     tothg:=jum*hrgs;
end;

function hrgd : real;
begin
     dis:=dis/100*tothg;
     hrgd:=tothg-dis;
end;

function hrgp : real;
begin
     jmlpj:=pj/100*tothg;
     hrgp:=tothg+jmlpj;
end;

{Main Program}
begin
     ulang:=true;
     while ulang do
     begin
          clrscr;
          writeln('        <<  MENU UTAMA >>        ');
          writeln('=================================');
          writeln('|  1. Hitung Total Harga        |');
          writeln('|  2. Hitung Diskon Harga       |');
          writeln('|  3. Hitung Pajak Total Harga  |');
          writeln('|  4. Selesai                   |');
          writeln('=================================');
          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);
                           writeln('Total Harga    :',tothg:6: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);
                           writeln('Total Harga    :',tothg:6:2);
                           writeln('Harga Bersih   :',hrgd:6: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);
                           writeln('Total Harga    :',tothg:6:2);
                           writeln('Harga Bersih   :',hrgp:6:2);
                           writeln;
                           write('Isi Lagi (Y/T) :');readln(lagi);
                      end;
               end;
               4:exit;
          end; {case}
     end; {while}
end.

Comments

Post a Comment

Terimakasih telah berkunjung dan berkomentar disini...

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