Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class Menu{
- private:
- public:
- void writeMenu(){
- cout<<"1. Order Pizza"<<endl;
- cout<<"2. Pay"<<endl;
- cout<<"3. Exit"<<endl;
- }
- void writePizzas(){
- cout<<"1. Meat lover pizza (@ Rp. 80000,-)"<<endl;
- cout<<"2. Vegetarian pizza (@ Rp. 50000,-)"<<endl;
- cout<<"Which pizza do you want to order[1-2]: ";
- }
- };
- struct data{
- int total;
- }pizza1, pizza2;
- int main(){
- system("cls");
- Menu menu;
- menu.writeMenu();
- int input;
- cin >> input;
- if(!cin){
- cin.clear();
- cin.ignore();
- main();
- } else {
- switch(input){
- case 1:
- STARTHERE:
- menu.writePizzas();
- cin>>input;
- if(!cin){
- cin.clear();
- cin.ignore();
- system("cls");
- goto STARTHERE;
- } else {
- switch(input){
- case 1:
- ++pizza1.total;
- break;
- case 2:
- ++pizza2.total;
- break;
- default:
- goto STARTHERE;
- break;
- }
- }
- cout<<"Thank you..."<<endl;
- main();
- break;
- case 2:
- if(pizza1.total > 0 || pizza2.total > 0){
- cout<<"You have ordered "<<pizza1.total<<" Meat Lover Pizza(s) and "<<pizza2.total<<" Vegetarian Pizza(s)."<<endl;
- cout<<"Total price : "<<(pizza1.total*80000)+(pizza2.total*50000)<<endl;
- ASKMONEY:
- cout<<"Input your money [minimum Rp. "<<(pizza1.total*80000)+(pizza2.total*50000)<<"] :";
- cin>>input;
- if(!cin){
- cin.clear();
- cin.ignore();
- system("cls");
- goto ASKMONEY;
- } else {
- if(input>=(pizza1.total*80000)+(pizza2.total*50000)){
- cout<<"Your change : Rp. "<<input-(pizza1.total*80000)+(pizza2.total*50000)<<endl;
- cout<<"Thank you..."<<endl;
- cin.clear();
- cin.ignore();
- getchar();
- }
- }
- } else {
- cout<<"You are not buy anything.."<<endl;
- cin.clear();
- cin.ignore();
- getchar();
- }
- main();
- break;
- case 3:
- cout<<"Thank you..."<<endl;
- exit(0);
- break;
- default: break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement