Kali ini aku akan memmberikan contoh membuat program penjualan sederhana menggunakan if dengan Turbo Pascal 7.1. dulu aku membuat program ini buat tugas kuliah pemrograman terstruktur. :)
ga' perlu banyak basa-basi karna emang udah basi sich.. :D
let's do!!
pertama tulis programnya kayak gini ya...
uses crt;
var napem,nb:string[15] ;
hrg,jb,jh,disc,tot:real;
begin
clrscr;
writeln;
writeln('----------------------------------------');
writeln(' DATA PENJUALAN BUAH SEGAR /KG');
writeln('----------------------------------------');
writeln;
write('Nama Pembeli = '); readln(napem);
writeln;
write('Buah Yang Dibeli = '); readln(nb);
writeln('.............................');
if nb='jeruk' then hrg:=5000 else
if nb='mangga' then hrg:=7000 else
if nb='apel' then hrg:=9000 else
if nb='duren' then hrg:=11000;
begin
end;
writeln;
write('Harga Buah =','Rp',hrg:6:0,'/Kg');
writeln;
writeln;
write('Jumlah Beli = '); readln(jb);
writeln;
jh:= hrg*jb;
write('Jumlah Harga =','Rp',jh:10:0);
writeln;
writeln('.............................');
writeln;
if jb > 3 then disc:=0.2*jh;
begin
end;
write('Anda Dapat Diskon=','Rp',disc:10:0);
writeln;
writeln('.............................');
writeln;
writeln;
write('Total Bayar =','Rp',hrg*jb-disc:10:0);
writeln;
writeln('----------------------------------------');writeln;
write('Terimakasih dan Tekan Enter');
readln;
end.
hemmzt cukup mudah bukan hehehe :)
kalo udah jadi ntar kayak gini....
ga' perlu banyak basa-basi karna emang udah basi sich.. :D
let's do!!
pertama tulis programnya kayak gini ya...
uses crt;
var napem,nb:string[15] ;
hrg,jb,jh,disc,tot:real;
begin
clrscr;
writeln;
writeln('----------------------------------------');
writeln(' DATA PENJUALAN BUAH SEGAR /KG');
writeln('----------------------------------------');
writeln;
write('Nama Pembeli = '); readln(napem);
writeln;
write('Buah Yang Dibeli = '); readln(nb);
writeln('.............................');
if nb='jeruk' then hrg:=5000 else
if nb='mangga' then hrg:=7000 else
if nb='apel' then hrg:=9000 else
if nb='duren' then hrg:=11000;
begin
end;
writeln;
write('Harga Buah =','Rp',hrg:6:0,'/Kg');
writeln;
writeln;
write('Jumlah Beli = '); readln(jb);
writeln;
jh:= hrg*jb;
write('Jumlah Harga =','Rp',jh:10:0);
writeln;
writeln('.............................');
writeln;
if jb > 3 then disc:=0.2*jh;
begin
end;
write('Anda Dapat Diskon=','Rp',disc:10:0);
writeln;
writeln('.............................');
writeln;
writeln;
write('Total Bayar =','Rp',hrg*jb-disc:10:0);
writeln;
writeln('----------------------------------------');writeln;
write('Terimakasih dan Tekan Enter');
readln;
end.
hemmzt cukup mudah bukan hehehe :)
kalo udah jadi ntar kayak gini....
Komentar