D4n9k3l's Blog
Just another WordPress.com weblog

Gabungan Array & Switch Case Bercabang

Soal :

Input :

Program Penjualan
‘Bebek Kremes Sambal Gledek’
Jl. KS Tubun No.29
Jakarta
=====================================================
Pesanan Ke :
Nama Pembeli :
Alamat :
Kode Menu [1/2/3] :
Pilihan Paket [a/b/c] :
Jumlah Beli :
Output :
——————————————————————–
No. | Nama Pembeli | Alamat | Menu | Paket | Harga | Total
——————————————————————–

——————————————————————–

Ingin Pesan Lagi [Y/T] :

Listing Program :

#include
#include
#include
#include
main()
{
int i,n,kode[5];
char nama[5][20],alamat[5][30],menu[5][10],paket[5],nmpaket[5][15],lg;
long int jumlah[5],harga[5],total[5];
d3d1:
clrscr();
cout<>n;
for (i=1;i<=n;i++)
{
clrscr();
cout<<"\t\t\tProgram Penjualan\n\t\t 'Bebek Kremes Sambal Geledek'\n\t\t\tJl. KS Tubun No.29\n\t\t\t Jakarta"<<endl;
cout<<"================================================================================"<<endl;
cout<<endl;
cout<<"Pesanan ke : "<<i<<endl;
cout<<"Nama Pembeli : ";gets(nama[i]);
cout<<"Alamat : ";gets(alamat[i]);
cout<>kode[i];
cout<>paket[i];
cout<>jumlah[i];
switch (kode[i])
{
case 1:
strcpy(menu[i],”HoT”);
switch (paket[i])
{
case ‘a’:
strcpy(nmpaket[i],”Single”);
harga[i]=45000;
break;
case ‘b’:
strcpy(nmpaket[i],”Double”);
harga[i]=60000;
break;
case ‘c’:
strcpy(nmpaket[i],”Combo”);
harga[i]=80000;
break;
default:
strcpy(nmpaket[i],”Error…!!!”);
harga[i]=0;
break;
}
break;
case 2:
strcpy(menu[i],”Asam Manis”);
switch (paket[i])
{
case ‘a’:
strcpy(nmpaket[i],”Single”);
harga[i]=30000;
break;
case ‘b’:
strcpy(nmpaket[i],”Double”);
harga[i]=60000;
break;
case ‘c’:
strcpy(nmpaket[i],”Combo”);
harga[i]=75000;
break;
default:
strcpy(nmpaket[i],”Error…!!!”);
harga[i]=0;
break;
}
break;
case 3:
strcpy(menu[i],”Rica-Rica”);
switch (paket[i])
{
case ‘a’:
strcpy(nmpaket[i],”Single”);
harga[i]=50000;
break;
case ‘b’:
strcpy(nmpaket[i],”Double”);
harga[i]=90000;
break;
case ‘c’:
strcpy(nmpaket[i],”Combo”);
harga[i]=115000;
break;
default:
strcpy(nmpaket[i],”Error…!!!”);
harga[i]=0;
break;
}
break;
default:
strcpy(menu[i],”Error…!!!”);
{
case ‘a’:
case ‘b’:
case ‘c’:
strcpy(nmpaket[i],”Error…!!!”);
harga[i]=0;
break;
}
break;
}
total[i]=harga[i]*jumlah[i];
}
clrscr();
cout<<"================================================================================"<<endl;
cout<<"No | Nama Pembeli | Alamat | Menu | Paket | Harga | Total "<<endl;
cout<<"================================================================================"<<endl;
for (i=1;i<=n;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(15)<<nama[i];
cout<<setiosflags(ios::left)<<setw(16)<<alamat[i];
cout<<setiosflags(ios::left)<<setw(13)<<menu[i];
cout<<setiosflags(ios::left)<<setw(13)<<nmpaket[i];
cout<<setiosflags(ios::left)<<setw(11)<<harga[i];
cout<<setiosflags(ios::left)<<setw(10)<<total[i];
cout<<endl;
}
cout<<"================================================================================"<<endl;
cout<>lg;
if(lg==’Y’||lg==’y’)
goto d3d1;
}

Tampilan Program :

Input
Input
Input
Output

Belum Ada Tanggapan to “Gabungan Array & Switch Case Bercabang”

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: