Membuat Program Kasir Dengan Bahasa Pascal
Program kasir;uses wincrt;var barang : array[1..20] of string;banyak : array[1..20] of real;
harga : array[1..20] of integer;kata,grs :string;
x,y,i,j : byte;
jum_harga,total_harga,diskon,total_bayar,uang : real;beginclrscr;grs:='==================================================================';
kata:='Prgram Kasir';
x:=round ((78-length(kata))/2);gotoxy(x,2) ;writeln(kata);x:=round ((78-length(grs))/2);gotoxy(x,3) ;write(grs);{-------------------------------------------}gotoxy(x,4);write('Data Belanja');
gotoxy(x,5);write(grs);gotoxy(x,6);writeln('| No | Nama Barang | Harga Barang |Banyak | Jumlah Barang| ');
{-----------------------------------------------------------------------------------------}i:=0;total_harga:=0;repeati:= i+1;gotoxy(x,7+i);write('|',i);
gotoxy(x+5,7+i);write('|');
gotoxy(x+7,7+i);readln(Barang[i]);if barang[i] <>'' thenbegingotoxy(x+25,7+i);write('|');
gotoxy(x+28,7+i);readln(harga[i]);gotoxy(x+28,7+i);writeln( harga [i] :10);gotoxy(x+41,7+i);write('|');
gotoxy(x+44,7+i);readln(banyak[i]);gotoxy(x+50,7+i);write('|');
jum_harga:=harga[i]*banyak[i];gotoxy(x+53,7+i);writeln(jum_harga:10:2);gotoxy(x+65,7+i);writeln('|');
total_harga:=total_harga+jum_harga;end;
until barang[i]='';
{------------------------------------------------------------------------------------------}diskon:=0;if (total_harga>10000) and (total_harga<100000) thendiskon:=0.05*total_harga {diskon bg pembeli antara 10rb-100}else
if (total_harga>=100000) thendiskon:=0.1*total_harga;{diskon bg pembeli lebih dr 100rb}{------------------------------------------------------------------------------------------}kata:='Faktur Penjualan';
y:=round((78-length(kata))/2);gotoxy(y,2);writeln(kata);j:=i-1;gotoxy(x,8+j);write(grs);gotoxy(x,8+j+1);write('Total Belanja');
gotoxy(x+53,8+j+1);write(total_harga:10:2);gotoxy(x,8+j+2);write('Discount');
gotoxy(x+53,8+j+3);write(diskon:10:2);gotoxy(x,8+j+3);write(grs);gotoxy(x,8+j+4);write('Total Bayar Setelah discount');
total_bayar:=total_harga-diskon;gotoxy(x+53,8+j+4);write(total_bayar:10:2);gotoxy(x,8+j+5);write('Uang dibayar');
gotoxy(x+53,8+j+5);readln(uang);gotoxy(x+53,8+j+5);writeln(uang:10:2);gotoxy(x,8+j+6);write(grs);gotoxy(x,8+j+7);write('Uang Kembali');
gotoxy(x+53,8+j+7);write(uang-total_bayar:10:2);end.
Jika Program tersebut kita RUN maka akan menghasilkan output seperti dibawah ini:
Comments
Post a Comment