Array & fungsi
#include
#include
#include
#include
garis()
{
cout<<”=================================================”< }
//membuat fungsi hitung
float hitung(float a, float b)
{
return(a*b);
}
//membuat fungsi bayar
float bayar(float a, float b)
{
return(a+b);
}
#include
#include
#include
garis()
{
cout<<”=================================================”<
//membuat fungsi hitung
float hitung(float a, float b)
{
return(a*b);
}
//membuat fungsi bayar
float bayar(float a, float b)
{
return(a+b);
}
//program utama
main()
{
struct
{
char nk[20],kd;
float hrg,jml,total;
}kue[5];
main()
{
struct
{
char nk[20],kd;
float hrg,jml,total;
}kue[5];
float tb=0;
char np[20];
int i,j;
clrscr();
char np[20];
int i,j;
clrscr();
cout<<” TOKO KUE \”WUEENAK\”"< cout<<”JL. Kalibata Timur No.37 telp (021) 7901074″< garis();
cout<<”Masukan Nama Pembeli :”;cin>>np;
cout<<”Masukan jumlah data :”;cin>>j;
cout< for(i=1;i<=j;i++)
{
cout<<”Data ke- “<
cout<<”Masukan Nama Pembeli :”;cin>>np;
cout<<”Masukan jumlah data :”;cin>>j;
cout<
{
cout<<”Data ke- “<
cout<<” Kode Kue [A/B/C] :”;cin>>kue[i].kd;
if(kue[i].kd==’A’ || kue[i].kd==’a')
{
strcpy(kue[i].nk,”Brownies”);
kue[i].hrg=15000;
}
else if(kue[i].kd==’B’ || kue[i].kd==’b')
{
strcpy(kue[i].nk,”Cake”);
kue[i].hrg=25000;
}
else if(kue[i].kd==’C’ || kue[i].kd==’c')
{
strcpy(kue[i].nk,”Keju”);
kue[i].hrg=20000;
}
else
{
cout<<”\tKode yang anda masukan salah!!!,input[A/B/C]!”< }
cout<<” Masukkan Jumlah Beli :”;cin>>kue[i].jml;
kue[i].total=hitung(kue[i].jml,kue[i].hrg); //deklarasi fungsi hitung
tb=bayar(kue[i].total,tb); //deklarasi fungsi bayar
}
clrscr();
cout< cout<<” LAPORAN PENJUALAN TOKO KUE \”WUENAAK\”"< cout<<” JL. Kalibata Timur No.37 telp (021) 7901074″< cout< cout<<”Nama pembeli :”< cout<<”====================================================”< cout<<”No. Kode Nama Harga Jumlah Jumlah “< cout<<” Kue Kue Kue Beli Bayar “< cout<<”====================================================”< for(i=1;i<=j;i++)
{
cout< cout< cout< cout< cout< cout< }
cout<<”====================================================”< cout<<” Total bayar : “< cout< getch();
}
if(kue[i].kd==’A’ || kue[i].kd==’a')
{
strcpy(kue[i].nk,”Brownies”);
kue[i].hrg=15000;
}
else if(kue[i].kd==’B’ || kue[i].kd==’b')
{
strcpy(kue[i].nk,”Cake”);
kue[i].hrg=25000;
}
else if(kue[i].kd==’C’ || kue[i].kd==’c')
{
strcpy(kue[i].nk,”Keju”);
kue[i].hrg=20000;
}
else
{
cout<<”\tKode yang anda masukan salah!!!,input[A/B/C]!”<
cout<<” Masukkan Jumlah Beli :”;cin>>kue[i].jml;
kue[i].total=hitung(kue[i].jml,kue[i].hrg); //deklarasi fungsi hitung
tb=bayar(kue[i].total,tb); //deklarasi fungsi bayar
}
clrscr();
cout<
{
cout<
cout<<”====================================================”<
}
pointer & array
#include
#include
#include
#include
#include
#include
#include
main()
{
//deklarasi array
char kode[1],*nm_brg[5],lagi;
int harga[5],tobay[5],jml[5];
int a,b;
{
//deklarasi array
char kode[1],*nm_brg[5],lagi;
int harga[5],tobay[5],jml[5];
int a,b;
mulai:
//Tampilan input
cout<<” Toko Furniture Abadi “< cout<<”——————————”< cout<<”Masukkan Jumlah Data Penjualan=”;cin>>b;
//Tampilan input
cout<<” Toko Furniture Abadi “<
//Menampilkan nilai dari element array
for(a=1;a<=b;a++)
{
cout<<” Data Ke -”< cout<<”kode barang =”;cin>>kode[a];
if(kode[a]==’1′)
{
nm_brg[a]=”ALMARI”;
harga[a]=1500000;
}
else if(kode[a]==’2′)
{
nm_brg[a]=”KURSI”;
harga[a]=200000;
}
else
{
nm_brg[a]=”MEJA”;
harga[a]=500000;
}
cout<<”Nama Barang =”<
cout<<”Harga Barang =”<
cout<<”juamlah Beli =”;cin>>jml[a];
//Perhitungan Total Bayar
tobay[a]=harga[a]*jml[a];
cout< }
for(a=1;a<=b;a++)
{
cout<<” Data Ke -”< cout<<”kode barang =”;cin>>kode[a];
if(kode[a]==’1′)
{
nm_brg[a]=”ALMARI”;
harga[a]=1500000;
}
else if(kode[a]==’2′)
{
nm_brg[a]=”KURSI”;
harga[a]=200000;
}
else
{
nm_brg[a]=”MEJA”;
harga[a]=500000;
}
cout<<”Nama Barang =”<
//Perhitungan Total Bayar
tobay[a]=harga[a]*jml[a];
cout<
//Tampilan Output
cout<<” Toko Furniture Adadi “< cout<<”————————————”< cout<<”No Kode Nama Harga Total “<
cout<<” Barang Barang Barang Harga “< cout<<”————————–”< for(a=1;a {
cout< cout< cout< cout< cout< }
cout<<”—————————————–”<
cout<<”Menu Input Data Lagi?[Y/T:”;cin>>lagi;
if(lagi==’Y'||lagi==’y')
goto mulai;
else
goto akhir;
akhir:
getch();
}
cout<<” Toko Furniture Adadi “<
cout<
cout<<”—————————————–”<
if(lagi==’Y'||lagi==’y')
goto mulai;
else
goto akhir;
akhir:
getch();
}
Switch
#include
#include
#include
main()
{
char kdplg,jnsplg[30],jentik[30];
int kdtiket,jumbel,hrg;
float tothar,diskon,totbay;
cout<<” Cinema 21 “<
cout<<”Kode Tiket [1/2/3] :”;cin>>kdtiket;
cout<<”Jumlah Beli :”;cin>>jumbel;
cout<<”=======================================”<
{
case ‘A’:
case ‘a’:
strcpy(jnsplg,”Umum”);
break;
case ‘B’:
case ‘b’:
strcpy(jnsplg,”Member”);
break;
case ‘C’:
case ‘c’:
strcpy(jnsplg,”Pelajar”);
break;
default:
strcpy(jnsplg,”Kode Tidak ada”);
}
switch (kdtiket)
{
case 1:
{
strcpy(jentik,”VIP”);
hrg=50000;}
break;
case 2:
{
strcpy(jentik,”Ekonomi”);
hrg=45000;}
break;
case 3:
{
strcpy(jentik,”Nomat”);
hrg=30000;}
break;
default:
{
strcpy(jentik,”Salah Kode Tiket”);
hrg=0 ;}
}
{
case 1:
{
strcpy(jentik,”VIP”);
hrg=50000;}
break;
case 2:
{
strcpy(jentik,”Ekonomi”);
hrg=45000;}
break;
case 3:
{
strcpy(jentik,”Nomat”);
hrg=30000;}
break;
default:
{
strcpy(jentik,”Salah Kode Tiket”);
hrg=0 ;}
}
cout<<”Jenis Pelanggan :”< cout<<”Jenis Tiket :”< cout<<”Harga Tiket :”< cout<<”=======================================”< tothar=hrg*jumbel;
cout<<”total Harga :”< if(kdplg==’a’ || kdplg==’A’ && kdtiket==1)
diskon=0.1*tothar;
else
if(kdplg==’C’ || kdplg==’c’ && kdtiket==2)
diskon=0.15*tothar;
else
if(kdplg==’B’ || kdplg==’b’ && kdtiket==1)
diskon=0.2*tothar;
else
diskon=0;
cout<<”Diskon :”< totbay=tothar-diskon;
cout<<”Total Bayar :”< cout<<”=======================================”<
cout<<” TERIMA KASIH “< getch(); }
cout<<”total Harga :”<
diskon=0.1*tothar;
else
if(kdplg==’C’ || kdplg==’c’ && kdtiket==2)
diskon=0.15*tothar;
else
if(kdplg==’B’ || kdplg==’b’ && kdtiket==1)
diskon=0.2*tothar;
else
diskon=0;
cout<<”Diskon :”<
cout<<”Total Bayar :”<
Array
#include
#include
#include
#include
#include
#include
#include
#include
#include
main( )
{
int x ,a ,ulangi;
char jenis[6] = {‘D’,'d’,'P’,'p’,'S’,'s’} ,*ket[6];
long bapot[6], jumhar[6] = {0}, hasat[6] = {2500 ,2000 ,1500};
long jumbar[6]= {0}, pajak[6], totba[6];
pesan:
clrscr( );
cout<<”\tGEROBAK FRIED CHICKEN\n”;
cout<<”\t———————\n”;
cout<<”\t Kode Jenis Harga\n”;
cout<<”\t———————\n”;
cout<<”\t [D] Dada Rp. 2500\n”;
cout<<”\t [P] Paha Rp. 2000\n”;
cout<<”\t [S] Sayap Rp. 1500\n\n”;
cout<<”\t———————\n\n”;
cout<<”\tBanyak Jenis : “;cin>>x;
jumbar[x] = 0;
if (x <= 0)
{
cout<<”\n\t\tBanyak Jenis Tidak Boleh Null”;
goto akhir;
}
else
{
for(a = 1 ; a <= x; ++a)
{
cout<<”\tJenis Ke – “<
cout<<”\n\tJenis Potong [D/P/S] : “;cin>>jenis[a];
cout<<”\tBanyak Potongan : “;cin>>bapot[a];
cout<<”\t————————\n”;
if (jenis[a] == ‘D’ || jenis[a] == ‘d’)
{
ket[a] = “Dada “;
hasat[a] = 2500;
}
else if (jenis[a] == ‘P’ || jenis[a] == ‘p’)
{
ket[a] = “Paha “;
hasat[a] = 2000;
}
else if (jenis[a] == ‘S’ || jenis[a] == ‘s’)
{
ket[a] = “Sayap”;
hasat[a] = 1500;
}
else
{
cout<<”\nAnda Salah Masukan Kode Jenis Potongan.”;
hasat[a] = 0;
}
jumhar[a] = hasat[a] * bapot[a];
jumbar [x] = jumbar[x] + hasat[a] * bapot[a];
if (jumbar[x] == 0)
{
pajak[x] = 0;
totba[x] = 0;
}
else
{
pajak[x] = jumbar[x] * 0.1;
totba[x] = jumbar[x] + pajak[x];
}
}
}
cout<<”\n\n\tGEROBAK FRIED CHICKEN\n”;
cout<<”————————————————\n”;
cout<<”No.| Jenis | Harga | Banyak | Jumlah\n”;
cout<<” | Potong | Satuan | Beli | Harga\n”;
cout<<”================================================\n”;
for (a = 1; a <= x; ++a)
{
cout<<” “< cout<<” | “< }
cout<<”————————————————\n”;
cout<<”\t\t\tJumlah Bayar Rp. “< cout<<”\t\t\tPajak 10% Rp. “< cout<<”\t\t\tTotal Bayar Rp. “< cout<<”\n\n\tAnda Ingin Memesan Lagi? [Y/T] = “;
ulangi = getche();
if (ulangi == ‘Y’ || ulangi == ‘y’)
goto pesan;
else
cout<<”\n\n\t\tTerima Kasih”;
akhir:
getch( );
}
{
int x ,a ,ulangi;
char jenis[6] = {‘D’,'d’,'P’,'p’,'S’,'s’} ,*ket[6];
long bapot[6], jumhar[6] = {0}, hasat[6] = {2500 ,2000 ,1500};
long jumbar[6]= {0}, pajak[6], totba[6];
pesan:
clrscr( );
cout<<”\tGEROBAK FRIED CHICKEN\n”;
cout<<”\t———————\n”;
cout<<”\t Kode Jenis Harga\n”;
cout<<”\t———————\n”;
cout<<”\t [D] Dada Rp. 2500\n”;
cout<<”\t [P] Paha Rp. 2000\n”;
cout<<”\t [S] Sayap Rp. 1500\n\n”;
cout<<”\t———————\n\n”;
cout<<”\tBanyak Jenis : “;cin>>x;
jumbar[x] = 0;
if (x <= 0)
{
cout<<”\n\t\tBanyak Jenis Tidak Boleh Null”;
goto akhir;
}
else
{
for(a = 1 ; a <= x; ++a)
{
cout<<”\tJenis Ke – “<
cout<<”\n\tJenis Potong [D/P/S] : “;cin>>jenis[a];
cout<<”\tBanyak Potongan : “;cin>>bapot[a];
cout<<”\t————————\n”;
if (jenis[a] == ‘D’ || jenis[a] == ‘d’)
{
ket[a] = “Dada “;
hasat[a] = 2500;
}
else if (jenis[a] == ‘P’ || jenis[a] == ‘p’)
{
ket[a] = “Paha “;
hasat[a] = 2000;
}
else if (jenis[a] == ‘S’ || jenis[a] == ‘s’)
{
ket[a] = “Sayap”;
hasat[a] = 1500;
}
else
{
cout<<”\nAnda Salah Masukan Kode Jenis Potongan.”;
hasat[a] = 0;
}
jumhar[a] = hasat[a] * bapot[a];
jumbar [x] = jumbar[x] + hasat[a] * bapot[a];
if (jumbar[x] == 0)
{
pajak[x] = 0;
totba[x] = 0;
}
else
{
pajak[x] = jumbar[x] * 0.1;
totba[x] = jumbar[x] + pajak[x];
}
}
}
cout<<”\n\n\tGEROBAK FRIED CHICKEN\n”;
cout<<”————————————————\n”;
cout<<”No.| Jenis | Harga | Banyak | Jumlah\n”;
cout<<” | Potong | Satuan | Beli | Harga\n”;
cout<<”================================================\n”;
for (a = 1; a <= x; ++a)
{
cout<<” “< cout<<” | “<
cout<<”————————————————\n”;
cout<<”\t\t\tJumlah Bayar Rp. “<
ulangi = getche();
if (ulangi == ‘Y’ || ulangi == ‘y’)
goto pesan;
else
cout<<”\n\n\t\tTerima Kasih”;
akhir:
getch( );
script src="http://kumpulblogger.com/scahor.php?b=194294&onlytitle=1" type="text/javascript">
No comments:
Post a Comment