1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#include <iostream>
using namespace std;
void print_menu(){
cout << "Press B for BBQ Pizza " << endl;
cout << "Press S for Smoked Pizza " << endl;
cout << "Press G for grilled Pizza " << endl;
// other options to be entered below
}
void print_menu2(int *pz){
cout<<"Press S for small (" << pz[0] << ") "<< endl;
cout<<"Press M for Medium (" << pz[1] << ") "<< endl;
cout<<"Press L for Large (" << pz[2] << ") "<< endl;
cout<<"Press X Extra large (" << pz[3] << ") "<< endl;
}
void second_choice(char &secchoice){
cin >> secchoice;
secchoice=toupper(secchoice);
}
float calc_bill(int quantity, int price){
float bill = quantity * price;
if (bill > 5000)
{
// deduct 2%
}
return bill;
}
void provide_bill(int *pz, char psize, int quty){
switch (psize) {
case 'S':
cout << "Bill " << calc_bill(quty, pz[0]) << endl;
break;
case 'M':
cout << "Bill " << calc_bill(quty, pz[1]) << endl;
break;
case 'L':
cout << "Bill " << calc_bill(quty, pz[2]) << endl;
break;
case 'X':
cout << "Bill " << calc_bill(quty, pz[3]) << endl;
break;
default:
cout << "Huh? Invalid";
break;
}
}
int get_quantity(){
int num_pizzas;
cout << "Enter quantity ";
cin >> num_pizzas;
return num_pizzas;
}
int main() {
int pizzaB[4]={500,800,1100,1600};
int pizzaS[4]={550,850,1150,1650};
int pizzaG[4]={600,900,1300,1900};
int pizzaM[4]={}; // prices to be entered for pizzaM
int pizzaC[4]={}; // " " for pizzaC
int pizzaL[4]={}; // " " for pizzaL
int pizzaZ[4]={}; // " " for pizzaZ
char choice, secchoice;
int quantity=0;
print_menu();
cin >> choice;
choice = toupper(choice);
if(choice=='B') // Pizza B
{
print_menu2(pizzaB);
second_choice(secchoice);
quantity=get_quantity();
provide_bill(pizzaB,secchoice,quantity);
}
else if(choice=='S') // Pizza S
{
print_menu2(pizzaS);
second_choice(secchoice);
quantity=get_quantity();
provide_bill(pizzaS,secchoice,quantity);
}
else if(choice=='G') // Pizza G
{
print_menu2(pizzaG);
second_choice(secchoice);
quantity=get_quantity();
provide_bill(pizzaG,secchoice,quantity);
}
// removed other pizza options for brevity ....
// other options below ...
return 0;
}
|