Senin, 24 Maret 2014

Codingan Program Beli Pizza C++


#include<iostream>

using namespace std;

void clear()
{
for(int i=0;i<25;i++)cout<<endl;
}

void main()
{
int opt;
int pizza, qtyM = 0, qtyV = 0;
double total = 0;
double money;

do
{
opt = 0;
clear();
cout<<"Welcome to Yummmy Delivery Pizza"<<endl;
cout<<"================================"<<endl;
cout<<"1.Order Pizza"<<endl;
cout<<"2.Pay"<<endl;
cout<<"3.Exit"<<endl<<endl;
do
{
cout<<"Choose :";
cin>>opt;cin.sync();cin.clear();
}while(opt< 1 || opt > 3);
switch(opt)
{
case 1:
pizza = 0;
clear();
cout<<"Choose an order"<<endl;
cout<<"==============="<<endl;
cout<<"1. Meat Lover Pizza (@ Rp. 80000,-)"<<endl;
cout<<"2. Vegetarian Pizza (@ Rp. 50000,-)"<<endl<<endl;
do{
cout<<"Which pizza do you want to order[1-2]: ";
cin>>pizza;
cin.sync(); cin.clear();
}while(pizza<1 || pizza>2);
if(pizza == 1)
{
total += 80000;
qtyM++;
}
else
{
total += 50000;
qtyV++;
}
cout<<"Thank you...";
cin.get();
break;
case 2:
clear();
if(total==0){
cout<<"You haven't bought anything.."<<endl;
}else{
cout<<"You have ordered " << qtyM << " Meat Lover Pizza(s) and " << qtyV << " Vegetarian Pizza(s)." <<endl << endl << endl;
cout<<"Total price : Rp. "<<total<<endl;
do{
cout<<"Input your money [minimum Rp. "<<total << "] :Rp. ";
cin>>money;
cin.sync(); cin.clear();
}while(money<total);
cout<<"Your change : Rp. "<<money-total<<endl;
total = 0;
qtyM = 0;
qtyV = 0;
cout<<"Thank you...";

}
cin.get();
break;
case 3:
clear();
printf("Thank you for buying our pizza...");
cin.get();
break;
}

}while(opt != 3);
}

Tidak ada komentar: