Home » » Program Toko Buku Program

Program Toko Buku Program

Written By Majelis Programmer on Senin, 16 Maret 2015 | Senin, Maret 16, 2015



Assalamu'alaikum warahmatullahi wabarakatuh......

Kali ini saya akan memberikan contoh program Toko Buku Program pada Borland C++ di dalam program menggunakan Fungsi, Struct, Array 1, For, IF Else dan GOTO.

Silahkan Salin Scrip yang di bawah untuk di Pelajari.


//MOCHAMMAD ABDUL AZIS
//12145140
//12.1A.27
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
buku()
{
cout<<"1.Buku Java   Rp.70.000-,"<<endl;
cout<<"2.Buku PHP    Rp.85.000-,"<<endl;
cout<<"3.Buku MySQL  RP.50.000-,"<<endl;
}
judul()
{
cout<<"======================================================="<<endl;
cout<<"\t\t       AZIS TEAMZ   "<<endl;
cout<<"\t\tTOKO BUKU PEMPROGRAMAN  "<<endl;
cout<<"======================================================="<<endl;
cout<<"PEMBELIAN DI ATAS Rp 200.000-, MENDAPATKAN POTONGAN 10%"<<endl;
cout<<"======================================================="<<endl;
}
garis()
{
cout<<"================================"<<endl;
}
garis1()
{
cout<<"====================================================="<<endl;
}

main()
{
struct
{
char kd_jenis[30],*jenis[30];
char ulangi,nm_kasir[20],nm_pembeli[20];
}nama;
int i,w,j,uk,ub,h;
long jml_byr,pajak,tot_byr;
int jml_beli[30];
long harga[30],jml_harga[30];
jml_byr=0;
atas:
clrscr();
judul();
buku();
garis();
cout<<endl;
cout<<"Input Nama Kasir    : ";gets(nama.nm_kasir);
cout<<"Input Nama Pembeli  : ";gets(nama.nm_pembeli);
cout<<"Jumlah Pembelian    : ";cin>>j;
cout<<endl;
clrscr();
buku();
garis();
for(i=1;i<=j;i++)
{
cout<<"Pembelian Ke- "<<i<<endl;
cout<<"Kode Buku[1/2/3]    : ";cin>>nama.kd_jenis[i];
cout<<"Jumlah Beli         : ";cin>>jml_beli[i];
garis();
}
//mencari jenis dan harga

for(i=1;i<=j;i++)
{
if(nama.kd_jenis[i]=='1')
{
nama.jenis[i]="Buku Java ";
harga[i]=70000;
}
else
if(nama.kd_jenis[i]=='2')
{
nama.jenis[i]="Buku PHP  ";
harga[i]=85000;
}
else
if(nama.kd_jenis[i]=='3')
{
nama.jenis[i]="Buku MySQL";
harga[i]=50000;
}
else
{
nama.jenis[i]="Kode Salah";
harga[i]=0;
jml_beli[i]=0;
}
}
clrscr();
judul();
cout<<"Nama Kaisir   :"<<nama.nm_kasir<<endl;
cout<<"Nama Pembeli  :"<<nama.nm_pembeli<<endl;
garis1();
cout<<"\nNo.         Jenis             Harga      Jumlah     Jumlah   \n";
cout<<"            Buku              Satuan      Beli       Harga   \n";
garis1();
for(i=1;i<=j;i++)
{
jml_harga[i]=jml_beli[i]*harga[i];
cout<<setiosflags(ios::left)<<setw(12)<<i;
cout<<setiosflags(ios::left)<<setw(0)<<nama.jenis[i];
cout<<setiosflags(ios::right)<<setw(12)<<harga[i];
cout<<setiosflags(ios::right)<<setw(12)<<jml_beli[i];
cout<<setiosflags(ios::right)<<setw(12)<<jml_harga[i]<<endl;
jml_byr=jml_byr+jml_harga[i];
pajak=jml_byr*3/100;
tot_byr=jml_byr+pajak;
}
garis1();
cout<<"\nJumlah Bayar   Rp."<<jml_byr<<endl;
cout<<"Pajak 3 %      Rp."<<pajak<<endl;
cout<<"Total Bayar    Rp."<<tot_byr<<endl;
if(tot_byr>200000)
{
w=(10*tot_byr)/100;
cout<<"Discount       Rp "<<w;
cout<<",-"<<endl;
cout<<endl;
}
else
{
w=0;
cout<<"Discount     Rp "<<w;
cout<<",-"<<endl;
cout<<endl;
}
h=tot_byr-w;
cout <<"Total Bayar    Rp."<<h<<endl;
cout <<"Uang Bayar     Rp.";cin>>ub;
uk = ub - h;
cout <<"Uang Kembali   Rp."<<uk<<endl;
garis1();
cout<<"Input Lagi [Y/T] :";
nama.ulangi = getche();
if (nama.ulangi == 'Y' || nama.ulangi == 'y')
goto atas;
else
cout<<"\n\n\t\tTerima Kasih";
akhir:
getch( );
}

1 komentar:

Popular Posts

Blog Archive