Coding Penjualan Koran
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
//function
char* koran(char kode)//pointer
{
if (kode=='R'||kode=='r')
{return "republka";}//penghitungan kembali
else if (kode=='M'||kode=='m')
{return "Media Indonesia";}
else if (kode=='S'||kode=='s')
{return "Sindo";}
}
int harga(char kode)
{
if (kode=='R'||kode=='r')
{return 2000;}
else if (kode=='M'||kode=='m')
{return 2500;}
else if (kode=='S'||kode=='s')
{return 3000;}
}
main()
{
struct
{
char kode,nama[25];
int ambil,kembali,jual,harga,total;
}
pengecer[50];
int i,j;
cout<<"\t**************************************"<<endl;
cout<<"\t =::=
NEWSPAPER AGENCY =::="<<endl;
cout<<"\t======================================"<<endl;
cout<<endl;
cout<<"Banyak Pengecer :";cin>>j;
cout<<endl;
for(i=1;i<=j;i++)
{
cout<<"Data Ke- "<<i<<endl;
cout<<"Nama Pengecer :";cin>>(pengecer[i].nama);
cout<<"Nama Koran :";cin>>pengecer[i].kode;
cout<<"Masukan Ambil :";cin>>pengecer[i].ambil;
cout<<"Masukan Kembali :";cin>>pengecer[i].kembali;
cout<<endl;
pengecer[i].jual=pengecer[i].ambil-pengecer[i].kembali;
pengecer[i].total=pengecer[i].jual*harga(pengecer[i].kode);
}
cout<<"\t \t\t\tNEWSPAPER AGENCY"<<endl;
cout<<"----------------------------------------------------------------------------"<<endl;
cout<<"No Nama Nama
Jumlah Jumlah
Jumlah Harga Total"<<endl;
cout<<" Pengecer Koran
ambil Kembali
Terjual Koran Penjualan"<<endl;
cout<<"-----------------------------------------------------------------------------"<<endl;
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(4)<<i;
cout<<setiosflags(ios::left)<<setw(13)<<pengecer[i].nama;
cout<<setiosflags(ios::left)<<setw(17)<<koran(pengecer[i].kode);
cout<<setiosflags(ios::left)<<setw(9)<<pengecer[i].ambil;
cout<<setiosflags(ios::left)<<setw(9)<<pengecer[i].kembali;
cout<<setiosflags(ios::left)<<setw(9)<<pengecer[i].jual;
cout<<setiosflags(ios::left)<<setw(9)<<harga(pengecer[i].kode);
cout<<setiosflags(ios::left)<<setw(4)<<pengecer[i].total;
cout<<endl;
}
cout<<"----------------------------------------------------------------------------"<<endl;
getch();
}
0 komentar:
Posting Komentar