Sourcode Kasir Rumah Makan
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class pretes{
public:
pretes();
void nokursi();
void menu();
void proses();
void output();
private:
int a,b,paket1,paket2,paket3,total;
char nama[20];
};
pretes::pretes(){
cout<<"Nama: Muhamad Jumadil Akbar "<<endl;
cout<<"Nim : 1400018093 "<<endl;
}
void pretes::nokursi(){
cout<<"=============================="<<endl;
cout<<"Pemesan nama dan kursi "<<endl;
cout<<"Masukan nama: "; cin>>nama;
do{
cout<<"Berapa kursi yang anda pesan : "; cin>>b;
}
while(b<1);
cout<<"Pemesanan jumlah kursi = "<<b<<endl;
for(int i=1;i<=b;i++){
int z = 0;
do{
if(z>0){
cout<<"No kursi Tidak Ada "<<endl;
}
cout<<"Masukan no kursi ke "<<(i)<<" : "; cin>>a;
z++;
}while(a<1);
if(a%2==0)
cout<<"Kursi no "<<a<<" ada di barisan sebelah kiri "<<endl;
else
cout<<"Kursi no "<<a<<" ada di barisan sebelah kanan "<<endl;
}
}
void pretes:: menu()
{ cout<<"=============================="<<endl;
cout<<"Berapa menu yang di pesan: ";
cin>>b;
cout<<"Pilihan menu:"<<endl;
cout<<"Paket 1 : nasi + Ayam + sambel + lalapan + es teh "<<endl;
cout<<"Paket 2 : nasi + lele + sambel + lalapan + es teh"<<endl;
cout<<"Paket 3 : nasi + bebek + sambel + lalapan + es teh"<<endl;
}
void pretes::proses(){
cout<<"=============================="<<endl;
total = 0;
for(int i=1; i<=b;i++){
cout<<"Masukan pilihan menu: "; cin>>a;
switch(a){
case 1:
paket1=9000;
cout<<"Paket 1: nasi + Ayam + sambel + lalapan + es teh = "<<paket1;
cout<<endl;
total = total+paket1;
break;
case 2:
paket2=8000;
cout<<"Paket 2: nasi + lele + sambel + lalapan + es teh ="<<paket2;
cout<<endl;
total = total+paket2;
break;
case 3:
paket3=10000;
cout<<"Paket 3: nasi + bebek + sambel + lalapan + es teh ="<<paket3;
cout<<endl;
total = total+paket3;
break;
default:
cout<<"menu tidak ada"<<endl;
break;
}
}
}
void pretes::output(){
cout<<"=============================="<<endl;
cout<<"Total yang harus di bayar = "<<total<<endl;
}
int main(int argc, char *argv[]) {
pretes k;
k.nokursi();
k.menu();
k.proses();
k.output();
return 0;
}
Output:
Tidak ada komentar:
Posting Komentar