#include <conio.h>
#include <iostream.h>
#include <stdio.h>
#include <iomanip.h>
//membuat struct sandal
struct sandal{
char kode_bar,*nama_bar;
float harga_bar,total_bay;
int jumlah_bar,diskon;
};
sandal sdl[30];
int pil,bts,i, t, r,s, cari, a,e,m,x;
char jwb;
char edit;
//Menu Utama
void menuUtama(){
clrscr();
cout<<"\t\t (*_*)....Selamat Datang....(*_*)"<<endl;
cout<<"\t\t Program Transaksi Jual/Beli Barang"<<endl;
cout<<"\t\t\t Toko Sandal Pita"<<endl;
cout<<"\t\t\ ------------------------------------------\n\n";
cout<<" \t\t\t *=* Menu Pilihan *=* "<<endl;;
cout<<"\t\t\t-------------------------------\n\n";
cout<<"\t\t\t [1] Tambah Data Barang\n"<<endl;
cout<<"\t\t\t [2] Tampilan Data Barang\n"<<endl;
cout<<"\t\t\t [3] Hapus Data Barang\n"<<endl;
cout<<"\t\t\t [4] Edit Data Barang\n"<<endl;
cout<<"\t\t\t [5] Keluar\n\n"<<endl;
cout<<"\t\t\t Pilihan [1..5] : ";
}
void inputData(){
char pil;
clrscr();
gotoxy(15,1);cout<<"\t\t + Tabel Daftar Sandal +"<<endl;
cout<<" \t\t---------------------------------------------------"<<endl;
cout<<" \t\t| Kode Barang | Nama Barang | Harga Satuan |"<<endl;
cout<<" \t\t--------------------------------------------------"<<endl;
cout<<" \t\t| C | Carvil | Rp 45000 |"<<endl;
cout<<" \t\t| B | Bata | Rp 55000 |"<<endl;
cout<<" \t\t| N | New Era | Rp 50000 |"<<endl;
cout<<" \t\t| W | Wedges | Rp 60000 |"<<endl;
cout<<" \t\t| H | HomyPed | Rp 75000 |"<<endl;
cout<<" \t\t| A | Ardiles | Rp 80000 |"<<endl;
cout<<" \t\t| O | Ando | Rp 35000 |"<<endl;
cout<<" \t\t---------------------------------------------------"<<endl<<endl;
cout<<" \t\t --------------------------------"<<endl;
cout<<"\t\t *=* Tambah Data Transaksi *=*"<<endl;
cout<<" \t\t --------------------------------\n"<<endl;
cout<<"\t => Masukan jumlah Barang yang ingin diinputkan : ";cin>>bts;
cout<<endl;
for (i=0; i<bts; i++)
{ cout<<"\t\t^_* Data ke- "<<i+1<<endl;
cout<<"\t\t -----------------------------------------\n"<<endl;
cout<<"\t\t -> Kode Barang : ";cin>>sdl[i].kode_bar;
if (sdl[i].kode_bar=='C')
{ sdl[i].nama_bar="Carvil";
sdl[i].harga_bar=45000;
}
else
if (sdl[i].kode_bar=='B')
{sdl[i].nama_bar="Bata";
sdl[i].harga_bar=55000;
}
else
if (sdl[i].kode_bar=='N')
{ sdl[i].nama_bar="New Era";
sdl[i].harga_bar=50000;
}
else
if (sdl[i].kode_bar=='W')
{sdl[i].nama_bar="Wedges";
sdl[i].harga_bar=60000;
}
if (sdl[i].kode_bar=='H')
{sdl[i].nama_bar="Homyped";
sdl[i].harga_bar=75000;}
if (sdl[i].kode_bar=='A')
{sdl[i].nama_bar="Ardiles";
sdl[i].harga_bar=80000;}
if (sdl[i].kode_bar=='O')
{sdl[i].nama_bar="Ando";
sdl[i].harga_bar=35000;}
cout<<"\t\t -> Nama Barang : "<<sdl[i].nama_bar<<endl;
cout<<"\t\t -> Harga Barang : Rp."<<sdl[i].harga_bar<<endl;
cout<<"\t\t -> Jumlah Barang : ";cin>>sdl[i].jumlah_bar;
if (sdl[i].jumlah_bar>10){
sdl[i].diskon=0.02*sdl[i].harga_bar*sdl[i].jumlah_bar;}
else
sdl[i].diskon=0;
cout<<"\t\t -> Diskon : Rp."<<sdl[i].diskon<<endl;
sdl[i].total_bay=sdl[i].harga_bar*sdl[i].jumlah_bar-sdl[i].diskon;
cout<<"\t\t -> Total Bayar : Rp."<<sdl[i].total_bay<<endl;
cout<<"\t -----------------------------------------"<<endl;}
cout<<endl<<endl;
cout<<("Mau Tambah Lagi..? [Y/T]:");
cin>>pil;
if (pil=='Y' || pil=='y')
inputData();
}
//tampil data barang
void tampilData(){
char pil;
clrscr();
cout<<"\t\t ------------------------------------"<<endl;
cout<<"\t\t =*** Laporan Jual/Beli Barang ***="<<endl;
cout<<"\t\t ------------------------------------\n\n"<<endl;
cout<<"----------------------------------------------------------------------"<<endl;
cout<<"No Kode Nama Harga Jumlah Diskon Total Bayar "<<endl;
cout<<"----------------------------------------------------------------------"<<endl;
for (i=0; i<bts; i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i+1;
cout<<setiosflags(ios::left)<<""<<setw(10)<<sdl[i].kode_bar;
cout<<setiosflags(ios::left)<<setw(10)<<sdl[i].nama_bar;
cout<<setiosflags(ios::left)<<setw(14)<<sdl[i].harga_bar;
cout<<setiosflags(ios::left)<<setw(10)<<sdl[i].jumlah_bar;
cout<<setiosflags(ios::left)<<setw(8)<<sdl[i].diskon;
cout<<setiosflags(ios::left)<<setw(20)<<sdl[i].total_bay<<endl;
cout<<"----------------------------------------------------------------------"<<endl;
}
cout<<endl<<endl;
cout<<"Kembali[Y/T]? :";
cin>>pil;
if (pil=='Y' || pil=='y')
menuUtama();
}
//hapus data barang
void hapusData(){
char pil;
char hapus;
clrscr();
cout<<"\t\t\t -------------------------------"<<endl;
cout<<"\t\t\t *= Hapus Data Barang *= "<<endl;
cout<<"\t\t\t -------------------------------\n\n"<<endl;
for (i=0; i<bts; i++)
{
cout<<"\t\t ^_* Data ke- "<<i+1<<endl;
cout<<"\t\t -> Kode Barang : "<<sdl[i].kode_bar<<endl;
cout<<"\t\t -> Nama Barang : "<<sdl[i].nama_bar<<endl;
cout<<"\t\t -> Harga Barang : Rp."<<sdl[i].harga_bar<<endl;
cout<<"\t\t -> Jumlah Barang : "<<sdl[i].jumlah_bar<<endl;
cout<<"\t\t -> Diskon : Rp."<<sdl[i].diskon<<endl;
cout<<"\t\t -> Total Bayar : Rp."<<sdl[i].total_bay<<endl; }
cout<<endl<<endl;
cout<<" Data ke Berapa Yang Akan Di Hapus : ";cin>>hapus;
cout<<"\t Data yang Baru \n ";
for(bts=hapus-1;bts<i-0;bts++){
sdl[x]=sdl[i-1];
}
for (bts=0; bts<i-1; bts++)
{
cout<<"\t^_* Data ke- "<<bts+1<<endl;
cout<<"\t -> Kode Barang : "<<sdl[bts].kode_bar<<endl;
cout<<"\t -> Nama Barang : "<<sdl[bts].nama_bar<<endl;
cout<<"\t -> Harga Barang : Rp."<<sdl[bts].harga_bar<<endl;
cout<<"\t -> Jumlah Barang : "<<sdl[bts].jumlah_bar<<endl;
cout<<"\t -> Diskon : Rp."<<sdl[bts].diskon<<endl;
cout<<"\t -> Total Bayar : Rp."<<sdl[bts].total_bay<<endl; }
cout<<endl;
cout<<"Hapus Data Lagi...? [Y/T] :";
cin>>pil;
if (pil=='Y' || pil=='y')
hapusData();
}
//edit data barang
void editData(){
char pil;
clrscr();
cout<<"\t\t\t\-------------------------------"<<endl;
cout<<"\t\t\t *= Edit Data Barang *= "<<endl;
cout<<"\t\t\t-------------------------------\n"<<endl;
for (i=0; i<bts; i++)
{
cout<<"\t^_* Data ke- "<<i+1<<endl;
cout<<"\t\t -> Kode Barang : "<<sdl[i].kode_bar<<endl;
cout<<"\t\t -> Nama Barang : "<<sdl[i].nama_bar<<endl;
cout<<"\t\t -> Harga Barang : Rp."<<sdl[i].harga_bar<<endl;
cout<<"\t\t -> Jumlah Barang : "<<sdl[i].jumlah_bar<<endl;
cout<<"\t\t -> Diskon : Rp."<<sdl[i].diskon<<endl;
cout<<"\t\t -> Total Bayar : Rp."<<sdl[i].total_bay<<endl;
cout<<"\t\t --------------------------------------------"<<endl;}
cout<<endl<<endl;
cout<<" Data Mana Yang Akan Di Edit ...? : ";cin>>edit;
for (i=1; i<bts; i++){
cout<<endl;
cout<<"\t\t Data yang Baru \n ";
cout<<"\t\t ____________________________________________________"<<endl;
cout<<"\t\t -> Kode Barang : ";cin>>sdl[i].kode_bar;
if (sdl[i].kode_bar=='C')
{ sdl[i].nama_bar="Carvil";
sdl[i].harga_bar=45000;
}
else
if (sdl[i].kode_bar=='B')
{sdl[i].nama_bar="Bata";
sdl[i].harga_bar=55000;
}
else
if (sdl[i].kode_bar=='N')
{ sdl[i].nama_bar="New Era";
sdl[i].harga_bar=50000;
}
else
if (sdl[i].kode_bar=='W')
{sdl[i].nama_bar="Wedges";
sdl[i].harga_bar=60000;
}
if (sdl[i].kode_bar=='H')
{sdl[i].nama_bar="Homyped";
sdl[i].harga_bar=75000;}
if (sdl[i].kode_bar=='A')
{sdl[i].nama_bar="Ardiles";
sdl[i].harga_bar=80000;}
if (sdl[i].kode_bar=='O')
{sdl[i].nama_bar="Ando";
sdl[i].harga_bar=35000;}
cout<<"\t\t -> Nama Barang : "<<sdl[i].nama_bar<<endl;
cout<<"\t\t -> Harga Barang : Rp."<<sdl[i].harga_bar<<endl;
cout<<"\t\t -> Jumlah Barang : ";cin>>sdl[i].jumlah_bar;
if (sdl[i].jumlah_bar>10){
sdl[i].diskon=0.02*sdl[i].harga_bar*sdl[i].jumlah_bar;}
else
sdl[i].diskon=0;
cout<<"\t\t -> Diskon : Rp."<<sdl[i].diskon<<endl;
sdl[i].total_bay=sdl[i].harga_bar*sdl [i].jumlah_bar-sdl[i].diskon;
cout<<"\t\t -> Total Bayar :Rp."<<sdl[i].total_bay<<endl;}
cout<<endl<<endl;
cout<<"Edit Data Lagi ....? [Y/T] :";
cin>>pil;
if (pil=='Y' || pil=='y')
editData();
getch();
}
void main(){
int pil;
do {
menuUtama();
cin>>pil;
switch (pil){
case 1 :
inputData();
break;
case 2 :
tampilData();
break;
case 3:
hapusData();
break;
case 4 :
editData();
break;
case 5 :
break;
}
}while(pil!=5);
}
Tidak ada komentar:
Posting Komentar