Jumat, 20 Juli 2012

contoh program penjualan dari pascal


semoga bermanfaat








USES CRT;
TYPE JUAL = RECORD
     NOMOR  : WORD;
     NAMA   : STRING;
     BARANG : STRING;
     MEMBER : CHAR;
     JUMLAH : INTEGER;
     HARGA  : REAL;
     DISKON : REAL;
     TOTAL  : REAL;
     BAYAR  : REAL;
END;
VAR
PILIHAN : CHAR;
NAMAFILE : FILE OF JUAL;
DATA : JUAL;
PROCEDURE BACA;
BEGIN
     ASSIGN(NAMAFILE,'DATAJUAL.TXT');{$I-}
     RESET(NAMAFILE);{$I+}
END;
PROCEDURE TAMBAH;
VAR
   ADA  : BOOLEAN;
   SELESAI : CHAR;
   NOCR : WORD;
   X   : INTEGER;
BEGIN
     CLRSCR;
     BACA;
     IF IORESULT <> 0 THEN REWRITE (NAMAFILE);
     REPEAT
     CLRSCR;
     ADA:=FALSE;
     X:=0;
     GOTOXY(19,12);WRITELN('===========================');
     GOTOXY(19,13);WRITELN('      FORM INPUT DATA');
     GOTOXY(19,14);WRITELN('---------------------------');
     GOTOXY(20,15);WRITE('NOMOR        : ');READLN(NOCR);
     WHILE (ADA=FALSE) AND (X<>FILESIZE(NAMAFILE)) DO
           BEGIN
                SEEK(NAMAFILE,X);
                READ(NAMAFILE,DATA);
                IF DATA.NOMOR=NOCR THEN
                ADA:=TRUE
           ELSE
               INC(X);
           END;
               IF (ADA=TRUE) THEN
                  BEGIN
                       GOTOXY(19,29);WRITE('NO. TRANSAKSI INI SUDAH ADA');READLN;
                  END
               ELSE
               BEGIN
                    SEEK(NAMAFILE,FILESIZE(NAMAFILE));
                    DATA.NOMOR:=NOCR;
                    GOTOXY(20,16);WRITE('NAMA         : ');READLN(DATA.NAMA);
                    GOTOXY(20,17);WRITE('MEMBER (Y/N) : ');READLN(DATA.MEMBER);
                    GOTOXY(20,18);WRITE('NAMA BARANG  : ');READLN(DATA.BARANG);
                    GOTOXY(20,19);WRITE('JUMLAH       : ');READLN(DATA.JUMLAH);
                    GOTOXY(20,20);WRITE('HARGA        : ');READLN(DATA.HARGA);
                    DATA.TOTAL:=DATA.JUMLAH*DATA.HARGA;
                    GOTOXY(20,21);WRITELN('TOTAL        : ',DATA.TOTAL:2:0);
                    IF (DATA.MEMBER='Y') OR (DATA.MEMBER='y') THEN
                    DATA.DISKON:=(5/100)*DATA.HARGA ELSE DATA.DISKON:=0;
                    GOTOXY(20,22);WRITELN('DISKON       : ',DATA.DISKON:2:0);
                    DATA.BAYAR:=DATA.TOTAL-DATA.DISKON;
                    GOTOXY(20,23);WRITELN('TOTAL BAYAR  : ',DATA.BAYAR:2:0);
                    GOTOXY(20,25);WRITE('SUDAH SELESAI : ');READLN(SELESAI);
                    WRITE(NAMAFILE,DATA);
               END;
     UNTIL (SELESAI='Y') OR (SELESAI='y');
     CLOSE(NAMAFILE);
END;
PROCEDURE TAMPIL;
VAR
   X : INTEGER;
   I : REAL;
BEGIN
     I:=0;
     BACA;
     IF IORESULT <> 0 THEN
     WRITE('MAAF BELUM ADA DATA')
     ELSE
     BEGIN
     CLRSCR;
     WRITELN('===========================================================================');
     WRITELN('                       LAPORAN DAFTAR PENJUALAN');
     WRITELN('                           TOKO DIPANEGARA');
     WRITELN('                    JL. PERINTIS KEMERDEKAAN KM 18');
     WRITELN('===========================================================================');
     WRITELN('|| NO |   NAMA   |  BARANG | JML |  HARGA  |  TOTAL  |  DISKON |  BAYAR  ||');
     WRITELN('---------------------------------------------------------------------------');
     X:=0;
     WHILE NOT EOF (NAMAFILE) DO
          BEGIN
               INC(X);
               READ(NAMAFILE,DATA);
               WRITELN('|| ',X:2,' | ',DATA.NAMA:8,' | ',DATA.BARANG:7,' | ',
               DATA.JUMLAH:3,' | ',DATA.HARGA:7:0,' | ',DATA.TOTAL:7:0,' | ',
               DATA.DISKON:7:0,' | ',DATA.BAYAR:7:0,' ||');
          END;
          CLOSE(NAMAFILE);
     END;
     WRITELN('===========================================================================');
     WRITELN;
     WRITELN('      YANG MEMBUAT');
     WRITELN;
     WRITELN;
     WRITELN;
     WRITELN;
     WRITELN('   (                 )');
     READLN;
END;
BEGIN
     CLRSCR;
     REPEAT
           CLRSCR;
           GOTOXY(19,12);WRITELN('=================================');
           GOTOXY(19,13);WRITELN('       PROGRAM PENJUALAN');
           GOTOXY(19,14);WRITELN('         OLEH MUHAMMAD ILHAM');
           GOTOXY(19,15);WRITELN('       STMIK DIPANEGARA MAKASSAR');
           GOTOXY(19,16);WRITELN('---------------------------------');
           GOTOXY(19,17);WRITELN('1. MENAMBAH DATA PENJUALAN');
           GOTOXY(19,18);WRITELN('2. MELIHAT DATA PENJUALAN');
           GOTOXY(19,19);WRITELN('3. KELUAR PROGRAM');
           GOTOXY(19,20);WRITELN('---------------------------------');
           GOTOXY(19,22);WRITELN('=================================');
           GOTOXY(19,21);WRITE('PILIHAN ANDA : ');READLN(PILIHAN);
           IF PILIHAN='1' THEN TAMBAH ELSE
           IF PILIHAN='2' THEN TAMPIL;
     UNTIL PILIHAN='3';
END.








illank bundrank

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 komentar:

Poskan Komentar