APLIKASI PENJUALAN SEDERHANA
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
typedef struct {
int hrg,jml;
char nomor[5],tgl[11],barang[15],pembeli[25];
} Rdata;
Rdata mdata;
FILE *fj;
void bukatulis();
void bukabaca();
void tutup();
void simpan();
void baca();
void transaksi();
void cetak();
int hitung();
void kwitansi();
void menu();
void main(){
menu();
}
void menu(){
int p=0;
while (p!=3) {
clrscr();
gotoxy(10, 5); cout<<" PENJUALAN ";
gotoxy(10, 7); cout<<" 1. Transaksi ";
gotoxy(10, 8); cout<<" 2. Laporan ";
gotoxy(10, 9); cout<<" 3. Selesai ";
gotoxy(10,11); cout<<" Pilih : "; cin>>p;
switch (p) {
case 1: { bukatulis();
transaksi();
simpan();
kwitansi();
tutup();
break;
}
case 2: { bukabaca();
cetak();
tutup();
break;
}
case 3: { cout<<"Terima Kasih..."<<endl;
getch();
break;
}
default:{
cout<<"Salah PILIH ..."<<endl;
getch();
}
}
}
}
void bukatulis(){
fj=fopen("Jual.dat","a");
}
void bukabaca(){
fj=fopen("Jual.dat","r");
}
void tutup(){
fclose(fj);
}
void simpan(){
fwrite(&mdata,sizeof(mdata),1,fj);
}
void baca(){
fread(&mdata,sizeof(mdata),1,fj);
}
void transaksi(){
clrscr();
cout<<" TRANSAKSI PENJUALAN "<<endl;
cout<<" Nomor kwit. : ";
cin>>mdata.nomor;
cout<<" Tanggal : ";
cin>>mdata.tgl;
cout<<" Nama Barang : ";
cin>>mdata.barang;
cout<<" Harga : Rp ";
cin>>mdata.hrg;
cout<<" Banyak : ";
cin>>mdata.jml;
cout<<" Nama Pembeli: ";
cin>>mdata.pembeli;
}
int hitung(){
int NB;
NB=mdata.hrg*mdata.jml;
return(NB);
}
void cetak(){
int x=0;
cout<<endl<<endl<<endl;
cout<<" LAPORAN PENJUALAN "<<endl;
cout<<" -------------------------------------------------------------------------"<<endl;
cout<<" No. Tgl Nama Pembeli Barang Banyak Harga Nilai Penjualan"<<endl;
cout<<" -------------------------------------------------------------------------"<<endl;
while (!feof(fj)) {
x++;
baca();
if (!feof(fj))
cout<<x<<" "<<mdata.tgl<<" "<<mdata.pembeli<<" "<<mdata.barang<<" "<<mdata.jml<<" @Rp "<<mdata.hrg<<" Rp "<<hitung()<<endl;
}
cout<<" -------------------------------------------------------------------------"<<endl;
getch();
}
void kwitansi(){
cout<<endl<<endl<<endl;
cout<<" KWITANSI "<<endl;
cout<<" Telah terima dari : "<<mdata.pembeli<<endl;;
cout<<" Uang sebesar Rp "<<hitung()<<endl;;
cout<<" Guna membayar "<<mdata.barang<<endl;;
cout<<" sebanyak: "<<mdata.jml<<" unit @Rp "<<mdata.hrg<<endl<<endl<<endl;
cout<<" Surakarta, "<<mdata.tgl<<endl<<endl<<endl;
cout<<" Dahlan Susilo"<<endl;
cout<<" -------------"<<endl;
cout<<" K a s i r "<<endl;
getch();
}
Bisa kirim flow chat nya ga ka
ReplyDeleteMkasih