olNGIb4NkK5r2x7x4oG3GpEzizVpnY6KNCck9cym

PROGRAM PASCAL PENJUALAN


Hai, semua sekian mengikuti mata kuliah Algoritma & Pemrograman 2B saya mendapat tugas yaitu membuat program penjualan seperti kasir. Dengan tekad dan kesabaran saya kerjain tugas ini akhirnya selesai program tersebut. Yuk kita lihat source code program tersebut, silahkan anda berkreasi pada source code agar tampilan atau ouputnya menjadi menarik.
Berikut ini adalah source code program pascal sebagai berikut :

program penjualan;
uses crt;
procedure show_data; { this procedure is used for showing both data stuff}
var
  w,len,x,i,posx,posy:integer;
  jml_beli,dt_i:integer;
  additem:char;
  tot_byr:array[1..10] of real;
  byr,hrg_sat_sel,t_hrg,tot_hrg:real;
  j:byte;

const
  { Constanta for title(header) }
   title='CREATED BY AFZAL ARIFIANSYAH || SHOPPING STORE';
  { U can change this title above as you want }
   line='"';                 { Style of line under title }
   wd=80;                    { width of window }
  { end }
  { name of goods }
  kd_brg:array[1..10] of integer=(1,2,3,4,5,6,7,8,9,10);
  nm_brg:array[1..10] of string[10]=('TINTA','HVS','LEM','TIPEX','FOLIO',
                                     'PENA','SPIDOL','BINDER','PENSIL','CD RW');
 { price of each goods }
  hrg_sat:array[1..10] of real=(17000,1000,4000,3000,500,2500,25000,3000,4000,5000);

begin
textcolor(14);

 { start creating header }

  len:=length(title);
  x:=(wd-len) div 2;

  gotoxy(x,1);writeln(title);

  for w:=1 to 80 do
   begin
    write(line); { give additional if you want }
   end;
 { end header }

 { Start the program }

  { show price list }
  textcolor(12);
   gotoxy(2,3);writeln('"Daftar Harga Barang"');
   gotoxy(1,4);write('Kode Barang');
   gotoxy(12,4);writeln('|   Harga   |');

   i:=1;
   while i<11 do
    begin
    textcolor(14);
    gotoxy(2,4+i);write(kd_brg[i]);gotoxy(5,4+i);write('|');gotoxy(6,4+i);write(nm_brg[i]);
     gotoxy(12,4+i);write('| Rp. ',hrg_sat[i]:0:0);gotoxy(24,4+i);writeln('|');
     inc(i); { auto increament }
    end;
   { end price }

end; { end of procedure show data }
     { Transaction }


label start;
var
  w,len,x,i,aa,pos_x,pos_y,wd_tb,tb:integer;
  dt_i,items:integer;
  jml_beli:array[1..100] of integer;
  ref,additem:char;
  con_byr,new:string[1];
  tot_byr:array[1..10] of real;
  tot_bayar,discount,sisa:real;
  t_hrg:array[1..10] of real;
  grand_tot,hrg_brg,hrg_sat_sel,tot_hrg,bayar:real;
  t:char;
  j:byte;
  const
  { Constanta for title(header) }
   title='CREATED BY AFZAL ARIFIANSYAH || SHOPPING STORE';  { U can change this title as you want }
   line='"';                 { Style of line under title }
   wd=80;                    { width of window }
  { end }
  kd_brg:array[1..10] of integer=(1,2,3,4,5,6,7,8,9,10);
  nm_brg:array[1..10] of string[10]=('TINTA','HVS','LEM','TIPEX','FOLIO',
                                     'PENA','SPIDOL','BUKU','PENSIL','SPIRAL'); { name of goods }
  hrg_sat:array[1..10] of real=(17000,1000,4000,3000,500,2500,25000,3000,4000,5000); { price of each goods }

begin
start:
     pos_x:=30;pos_y:=3;                { adjust your position you want to start }
     gotoxy(pos_x,pos_y);write('Transaksi Penjualan'); { Coordinat to start Transaction }
   dt_i:=0;

   repeat
      ClrScr;
      show_data; { call procedure }
      inc(dt_i);;
      textcolor(11);
      gotoxy(pos_x+10,pos_y);writeln('Transaksi : ');
      gotoxy(pos_x,pos_y+1);write('Kode Barang : ');readln(kd_brg[dt_i]); { readln is very crucial here }
      gotoxy(pos_x+27,pos_y+1);writeln('@  Rp. ',hrg_sat[kd_brg[dt_i]]:0:0);
      gotoxy(pos_x,pos_y+2);write('Jumlah Beli : ');readln(jml_beli[dt_i]);     { readln is needed on the last variable }

      { Pattern }
       {t_hrg:=hrg_sat[kd_brg[dt_i]] * jml_beli;}
       t_hrg[dt_i]:=hrg_sat[kd_brg[dt_i]]*jml_beli[dt_i];
      { end pattern }
      gotoxy(pos_x+23,pos_y+2);writeln('T_hrg  Rp. ',t_hrg[dt_i]:0:0);

      gotoxy(pos_x,pos_y+4);write('Tambahkan item ? Y/N : ');readln(additem);

   until UpCase(additem)<>'Y';


 begin
   { create table for note }
     textcolor(15);
     wd_tb:=54;
     gotoxy(pos_x-3,pos_y+5);
     for wd_tb:=1 to wd_tb do
      write('-');
     gotoxy(pos_x-3,pos_y+7);
     for wd_tb:=1 to wd_tb do
      write('-');
     gotoxy(pos_x-3,pos_y+6);write('| item |  Nama Barang  |   Harga(Rp)  |  T_Harga(Rp) |');
     items:=dt_i;
     for dt_i:=1 to items do
     begin
      gotoxy(pos_x,pos_y+7+dt_i);write(jml_beli[dt_i]);
      gotoxy(pos_x+6,pos_y+7+dt_i);write(nm_brg[kd_brg[dt_i]]);
      gotoxy(pos_x+23,pos_y+7+dt_i);write(hrg_sat[kd_brg[dt_i]]:0:0);
      gotoxy(pos_x+40,pos_y+7+dt_i);write(t_hrg[dt_i]:0:0);

     end;

     {here is used for calculate total payment }

     for dt_i:=1 to items do
     grand_tot:=grand_tot+t_hrg[dt_i]; { Important }
     {
     case grand_tot of
         1000..10000 : discount:=0;
         100001..50000: discount:=1000;
     else
        discount:=5000;
     end;
     }
     if grand_tot<10001 then
      discount:=0
     else
     if grand_tot<50001 then
      discount:=1000
     else
     if grand_tot<100001 then
      discount:=5000
     else
     if grand_tot<500001 then
      discount:=10000
     else
     if grand_tot<100001 then
      discount:=200000
     else
      discount:=300000;
     tot_bayar:=grand_tot-discount;
     gotoxy(pos_x-3,pos_y+8+items);
     for wd_tb:=1 to wd_tb do
      write('-');
     gotoxy(pos_x+21,pos_y+9+items);write('Grand Total : Rp. ');
     gotoxy(pos_x+40,pos_y+9+items);writeln(grand_tot:0:0);
gotoxy(pos_x-3,pos_y+10+items);write('Discount : Rp. ');          write(discount:0:0);
     gotoxy(pos_x+21,pos_y+11+items);write('Total Bayar : Rp. ');
     gotoxy(pos_x+40,pos_y+11+items);write(tot_bayar:0:0);
     gotoxy(pos_x-3,pos_y+12+items);write('Bayar : Rp. ');
     readln(bayar);
     sisa:=bayar-tot_bayar;
     gotoxy(pos_x+21,pos_y+12+items);write('Kembali     : Rp. ');
     gotoxy(pos_x+40,pos_y+12+items);write(sisa:0:0);


 end;
   {end table }
   textcolor(14);
   gotoxy(pos_x-3,pos_y+15+items);write('Press "Enter", jika transaksi selesai : ');
   readln(con_byr);
    ClrScr;

    gotoxy(21,2);writeln('||      ||  || |||||| |||||| |||||| ');
    gotoxy(21,3);writeln('||      ||  || ||  || ||  || ||     ');
    gotoxy(21,4);writeln('||      ||  || ||  || ||  ||  ||    ');
    gotoxy(21,5);writeln('||      ||  || ||  || ||||||    ||  ');
    gotoxy(21,6);writeln('||      ||  || ||  || ||  ||     || ');
    gotoxy(21,7);writeln('||||||  |||||| ||  || ||  || |||||| ');

    gotoxy(19,10);writeln('==> Terima kasih atas kunjungan anda <==');

    gotoxy(9,11);writeln('"Barang yang sudah dibeli tidak dapat ditukar/dikembalikan"');

   gotoxy(1,25);write('Press "Enter" untuk transaksi baru..:  ');read(new);


   ClrScr;
   goto start;
 { End program }
end.

Semoga ilmunya bermanfaat bagi kita semua yaa gaes...

Related Posts

Posting Komentar