Selasa, 17 Desember 2013

Contoh Pascal


Tugas Tambahan Nilai Pascal

Program prosedur;
uses
     wincrt;
var
     pil,jb:integer;
     diskon,hasil,harga,total,tb:real;
     jawab:string;
procedure menu;
begin
     writeln('Penjualan Laptop');
     writeln('--------- ------');
     writeln('1. Toshiba');
     writeln('2. Acer');
     writeln('3. Axio');
     writeln('4. Asus');
end;

procedure toshiba;
begin
     harga:=4000000;
end;

procedure Acer;
begin
     harga:=3000000;
end;

procedure Axio;
begin
     harga:=2500000;
end;

procedure Asus;
begin
     harga:=2000000;
end;

procedure baca_dimensi;
begin
     writeln('Harga = ',harga:1:0);
     Write('Jumlah Beli = ');readln(jb);
end;

procedure pembayaran;
begin
     Total:=jb*harga;
     if total >=7500000 then diskon:= 0.1*total else diskon :=0;
     tb:=total-diskon;
end;
procedure Tampil_Hasil;
begin
     writeln('Total Pembelian = Rp. ',Total:1:0);
     writeln('Diskon = Rp.',Diskon:1:0);
     writeln('Total Bayar = Rp. ',tb:1:0);  
end;

begin
repeat
     menu;
     write('Masukkan Pilihan Anda: '); readln(pil);
     case pil of
     1: toshiba;
     2: Acer;
     3: Axio;
     4: Asus
     else writeln('Pilihan Anda Salah....Ulangi!!');
     end;
     if pil<5 then baca_dimensi;
     pembayaran ;
     if pil <5 then Tampil_Hasil;
     write('Mau Diulang (Y/T)? ');readln(Jawab);
     writeln;
until Jawab='T';    
end.