//Deklarasi Header #include<iostream.h> #include<stdio.h> #include<conio.h> main() { //Deklarasi Variabel struct { char kd_jen_pak,*paket,kd_jen_atr,*atraksi, *bonus; long hrg_paket, hrg_atraksi, diskon; }resto; char nama[25], lagi; int bayar, total,u_bayar,u_kembali; atas: //Deklarasi Input clrscr(); cout<<" BIRTHDAY PARTY 4 U "<<endl; cout<<"------------------------------------------------"<<endl; cout<<"Nama Pemesan : ";gets(nama); cout<<endl; ulangkd_jen_pak: cout<<"Jenis Paket"<<endl; cout<<"[1]Paket Mewah, harga Rp 2.000.000,-"<<endl; cout<<"[2]Paket Sedang, harga Rp 1.500.000,-"<<endl; cout<<"[3]Paket Sederhana,harga Rp 1.000.000,-"<<endl; cout<<"Jenis paket yang di pilih [1/2/3] : ";cin>>resto.kd_jen_pak; cout<<endl; ulangkd_jen_atr: cout<<"[B]Badut, Harga Rp 300.000,-"<<endl; cout<<"[P]Sulap, Harga Rp 500.000,-"<<endl; cout<<"[S]Penyanyi Cilik, Harga Rp 600.000,-"<<endl; cout<<"Jenis Atraksi yang di pilih [B/P/S] : ";cin>>resto.kd_jen_atr; //Deklarasi Percabangan switch(resto.kd_jen_pak) { case '1': {resto.hrg_paket=2000000; resto.paket="Paket Mewah";} break; case '2': {resto.hrg_paket=1500000;resto.paket="Paket Sedang";} break; case '3': {resto.hrg_paket=1000000;resto.paket="Paket Sederhana";} break; default: cout<<"Jenis Paket salah..!"<<endl; goto ulangkd_jen_pak; break; } switch(resto.kd_jen_atr) { case 'B': case 'b': {resto.hrg_atraksi=300000;resto.atraksi="Badut";} break; case 'P': case 'p': {resto.hrg_atraksi=500000;resto.atraksi="Sulap";} break; case 'S': case 's': {resto.hrg_atraksi=600000;resto.atraksi="Penyanyi Cilik";} break; default: cout<<"Jenis Atraksi salah..!"<<endl; goto ulangkd_jen_atr; break; } total=resto.hrg_atraksi+resto.hrg_paket; if(total>=2000000) {resto.diskon=0.1*total;resto.bonus="Black Forest";} else {resto.diskon=0;resto.bonus="Maaf Tidak Dapat Bonus";} bayar=total-resto.diskon; clrscr(); cout<<" BIRTHDAY PARTY 4 U"<<endl; cout<<"---------------------------------------"<<endl; cout<<"Nama Pemesan : "<<nama<<endl; cout<<"Paket Pilihannya Adalah : "<<resto.paket<<endl; cout<<"Harga Per-Paket : "<<resto.hrg_paket<<endl; cout<<"Atraksi Pilihan : "<<resto.atraksi<<endl; cout<<"Harga Atraksi : "<<resto.hrg_atraksi<<endl; cout<<"---------------------------------------"<<endl; cout<<"Bonus : "<<resto.bonus<<endl; cout<<"---------------------------------------"<<endl; cout<<"Total Keseluruhan : "<<total<<endl; cout<<"Potongan yang diperoleh : "<<resto.diskon<<endl; cout<<"Total Bayar : "<<bayar<<endl; cout<<"Uang Bayar : ";cin>>u_bayar; u_kembali=u_bayar-bayar; cout<<"Uang Kembali : "<<u_kembali<<endl; cout<<"---------------------------------------"<<endl; cout<<"Mau Input Data Lagi[Y/T]:";cin>>lagi; if(lagi=='y'||lagi=='Y') {goto atas;} getch(); }
Contoh Structure & Switch-case
Posted In
12.1C.07,
Algoritma dan Pemrograman,
BSI,
Semester I
- 6/09/2012 - 0
comments
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment