Oct 15, 2015 at 4:50am UTC
How will i code if i want to delete my previous order and to limit the order per item
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
///this is a function
int exitP(int x){
cout<<"Would you like to buy again? [1 -> yes :: 2 -> no]: " ;
cin>>x;
///this is a switch
switch(x){
case 1: return(x);
break;
case 2: cout<<"Goodbye!";
exit(x);
break;
default: cout<<"Pls enter numbers 1-2 only. ";
exitP(x);
break;
}
}
int main(int argc, char** argv) {
char o;
string name;
int Money;
double item1 = 70;
double item2 = 60;
double item3 = 35;
double item4 = 30;
double item5 = 35;
double item6 = 35;
double Money = 0;
int exitProgram = 1;
cout<<"Welcome to DrinkIt"<<endl;
cout<<endl;
cout<<"Good Afternoon Whats Your Name Sir? : ";
getline(cin,name);
cout<<"Sir "<<name;
cout<<endl;
cout<<endl;
cout<<"How much is your money: "<<endl;
cin>>Money;
while (Money >= 30 && exitProgram == 1)
{
cout<<"Choose your drink:\n (a.colt45 (P70), b.redhorse (P60), c.coke (P35), d.pepsi (P30), e.mango shake (P35), f.sprite (P35)): "<<endl;
cout<<endl;
cin>>o;
cout<<endl;
switch(o){
case 'a':
cout<<"colt45"<<endl;
Money = Money - item1;
cout<<"Your have P "<<Money<<"left"<<endl;
exitP(exitProgram);
break;
case 'b':
cout<<"redhorse"<<endl;
Money = Money - item2;
cout<<"Your have P "<<Money<<"left"<<endl;
exitP(exitProgram);
break;
case 'c':
cout<<"coke";
Money = Money - item3;
cout<<"Your have P "<<Money<<"left"<<endl;
exitP(exitProgram);
break;
case 'd':
cout<<"pepsi";
Money = Money - item4;
cout<<"Your have P "<<Money<<"left"<<endl;
exitP(exitProgram);
break;
case 'e':
cout<<"mango shake" ;
Money = Money - item5;
cout<<"Your have P "<<Money<<"left"<<endl;
exitP(exitProgram);
break;
case 'f':
cout<<"sprite";
Money = Money - item6;
cout<<"Your have P "<<Money<<"left"<<endl;
exitP(exitProgram);
break;
defualt:
cout<<"Choose only a-f "<<endl;
}
}
cout << "You don't have enough money to purchase anything else. Thank you for shopping!";
return 0;
}