-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPizza.cpp
More file actions
273 lines (263 loc) · 9.81 KB
/
Pizza.cpp
File metadata and controls
273 lines (263 loc) · 9.81 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#include<stdio.h>
#include<string.h>
void DisplayOrder(struct PizzaTypes pizzaCart[100],struct PizzaCost costOnSize[12],char itemNames[12][100],int sidesCost[4]);
struct PizzaTypes{
int smallQuantity,mediumQuantity,largeQuantity,others,freshPan,cheeseBurst,wheatThinCrust;
};
struct PizzaCost{
int smallCost,mediumCost,largeCost,freshPanCost,cheeseBurstCost,wheatThinCrustCost;
};
main()
{
int i=0,c=1,j=0,mainChoice,cost[24]={99,195,395,155,295,445,155,295,445,195,365,545,155,295,445,225,425,635,235,455,685,235,455,685},totalCost=0,a[10];
char name[20];
char itemNames[12][100]={
"Margherita(Veg)",
"Spicy Triple Tango(Veg)",
"Double Cheese Margherita(Veg)",
"Farm House(Veg)",
"Cheese and Barbeque Chicken(Non Veg)",
"Chicken Fiesta(Non Veg)",
"Chicken Mexican(Non Veg)",
"Chicken Golden Delight(Non Veg)",
"Zingy Parcel Veg",
"Zingy Parcel Non Veg",
"Taco Mexicana Veg",
"Taco Mexicana Non Veg"
};
int sidesCost[4]={29,35,119,129};
// int zingyParcelVeg=29,zingyParcelNonVeg=35,tacoMexicanaVeg=119,tacoMexicanaNonVeg=129;
struct PizzaTypes pizzaCart[100];
struct PizzaCost costOnSize[12];
for(i=0;i<12;i++)
{
pizzaCart[i].smallQuantity=0;
pizzaCart[i].mediumQuantity=0;
pizzaCart[i].largeQuantity=0;
pizzaCart[i].freshPan=0;
pizzaCart[i].wheatThinCrust=0;
pizzaCart[i].cheeseBurst=0;
pizzaCart[i].others=0;
}
i=0;
while(i<24)
{
costOnSize[j].smallCost=cost[i++];
costOnSize[j].mediumCost=cost[i++];
costOnSize[j].largeCost=cost[i++];
costOnSize[j].freshPanCost=30;
costOnSize[j].cheeseBurstCost=95;
costOnSize[j].wheatThinCrustCost=40;
j++;
}
do{
if(c==1){
printf("Enter\n1 - Veg Pizzas\n2 - Chicken Pizzas\n3 - Sides\n4 - Exit\n");
scanf("%d",&mainChoice);
switch(mainChoice)
{
case 1:
{
int subChoice;
printf("Enter\n1 - Margherita\n2 - Spicy Triple Tango\n3 - Double Cheese Margherita\n4 - Farm House\n5 - Exit\n");
scanf("%d",&subChoice);
if(subChoice!=5){
int sizeChoice;
printf("Enter\n1 - Small\n2 - Medium\n3 - Large\n");
scanf("%d",&sizeChoice);
if(sizeChoice==1)
pizzaCart[subChoice-1].smallQuantity++;
if(sizeChoice==2)
pizzaCart[subChoice-1].mediumQuantity++;
if(sizeChoice==3)
pizzaCart[subChoice-1].largeQuantity++;
printf("Need Special Crusts\n1 - Fresh Pan\n2 - Cheese Burst\n3 - Wheat thin Crust\n4 - No Need\n");
int extraCrust;
scanf("%d",&extraCrust);
if(extraCrust==1)
pizzaCart[subChoice-1].freshPan++;
else if(extraCrust==2)
pizzaCart[subChoice-1].cheeseBurst++;
else if(extraCrust==3)
pizzaCart[subChoice-1].wheatThinCrust++;
if(subChoice!=5)
printf("Pizza Added to Cart Successfully\n");
}
break;
}
case 2:
{
int subChoice;
printf("Enter\n1 - Cheese and Barbeque Chicken\n2 - Chicken Fiesta\n3 - Chicken Mexican\n4 - Chicken Golden Delight\n5 - Exit\n");
scanf("%d",&subChoice);
if(subChoice!=5){
int sizeChoice;
printf("Enter\n1 - Small\n2 - Medium\n3 - Large\n");
scanf("%d",&sizeChoice);
if(sizeChoice==1)
pizzaCart[subChoice+4-1].smallQuantity++;
if(sizeChoice==2)
pizzaCart[subChoice+4-1].mediumQuantity++;
if(sizeChoice==3)
pizzaCart[subChoice+4-1].largeQuantity++;
printf("Need Special Crusts\n1 - Fresh Pan\n2 - Cheese Burst\n3 - Wheat thin Crust\n4 - No Need\n");
int extraCrust;
scanf("%d",&extraCrust);
if(extraCrust==1)
pizzaCart[subChoice+4-1].freshPan++;
else if(extraCrust==2)
pizzaCart[subChoice+4-1].cheeseBurst++;
else if(extraCrust==3)
pizzaCart[subChoice+4-1].wheatThinCrust++;
if(subChoice!=5)
printf("Pizza Added to Cart Successfully\n");
}
break;
}
case 3:
{
int subChoice;
printf("Enter\n1 - Zingy Parcel Veg\n2 - Zingy Parcel Non Veg\n3 - Taco Mexican Veg\n4 - Taco Mexican Non Veg\n5 - Exit\n");
scanf("%d",&subChoice);
if(subChoice<5 && subChoice>0)
pizzaCart[subChoice+8-1].others++;
if(subChoice!=5)
printf("Added to Cart Successfully\n");
break;
}
default:
{
printf("Invalid Choice\n");
break;
}
}
}
if(c==2)
{
int id,quantityPizza,quantityCrust,quantity,wrongIdFlag=1;
printf("Enter Id to change Quantity\n");
scanf("%d",&id);
if(id>=0 && id<=11)
{
if(id>=0&&id<=7)
{
if(pizzaCart[i].smallQuantity>0||pizzaCart[i].mediumQuantity>0||pizzaCart[i].largeQuantity||pizzaCart[i].others>0||pizzaCart[i].freshPan>0||pizzaCart[i].cheeseBurst||pizzaCart[i].wheatThinCrust>0){
printf("Enter\n1 - To Change Small Pizza Quantity\n2 -Change Quantity for Medium Pizza\n3 -Change Quantity for Large Pizza\n4 -Change Quantity for Crust\n5 - Exit\n");
scanf("%d",&quantityPizza);
printf("Enter quantity to change and to delete Enter 0\n");
scanf("%d",&quantity);
if(quantity>=0){
if(quantityPizza==1)
pizzaCart[id].smallQuantity=quantity;
if(quantityPizza==2)
pizzaCart[id].mediumQuantity=quantity;
if(quantityPizza==3)
pizzaCart[id].largeQuantity=quantity;
if(quantityPizza==4)
{
printf("Enter\n1 - To Change Fresh Pan\n2 - Cheese Burst\n3 - Wheat Thin Crust\n4 - Exit\n");
scanf("%d",&quantityCrust);
if(quantityCrust==1)
pizzaCart[id].freshPan=quantity;
if(quantityCrust==2)
pizzaCart[id].cheeseBurst=quantity;
if(quantityCrust==3)
pizzaCart[id].wheatThinCrust=quantity;
}
}
else{
printf("Enter Quantity greater than or equal to zero\n");
}
}
else{
printf("Id Not Found\n");
wrongIdFlag=0;
}
}
else{
printf("Enter\n1 - To Change Quantity of Zingy Parcel(Veg)\n2 - To Change Quantity of Zingy Parcel(Non Veg)\n3 - To Change Quantity of Taco Mexicana(Veg)\n4 - To Change Quantity of Taco Mexicana(Non Veg)\n5 - To Change Quantity of - Exit\n");
scanf("%d",&quantityPizza);
if(quantityPizza>=1 && quantityPizza<=4)
{
printf("Enter quantity\n");
scanf("%d",&quantity);
pizzaCart[id].others=quantity;
}
}
if(wrongIdFlag==1)
{
printf("Quantity Changed Successfully\nRearranged Order is\n");
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
}
}
else{
printf("Please Enter Valid Id\n");
}
}
if(c==4)
{
int id;
printf("Enter Id to delete from Cart\n");
scanf("%d",&id);
pizzaCart[id].smallQuantity=0;
pizzaCart[id].mediumQuantity=0;
pizzaCart[id].largeQuantity=0;
pizzaCart[id].others=0;
pizzaCart[id].freshPan=0;
pizzaCart[id].cheeseBurst=0;
pizzaCart[id].wheatThinCrust=0;
printf("Item Deleted Successfully\nRearranged Order is\n");
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
}
if(c==3)
{
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
}
printf("Enter\n1 - Add Item\n2 - Change Quantity\n3 - View Cart\n4 - Delete from Cart\nElse any number to Calculate Cost\n");
scanf("%d",&c);
}while(c==1 || c==2 || c==3 || c==4);
printf("Final Order \n");
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
printf("Thanks for Shopping with us\n");
}
void DisplayOrder(struct PizzaTypes pizzaCart[100],struct PizzaCost costOnSize[12],char itemNames[12][100],int sidesCost[4])
{
int totalCost=0,i;
printf("---------------------List in Cart-------------------------\n");
for(i=0;i<11;i++)
{
if(pizzaCart[i].smallQuantity>0||pizzaCart[i].mediumQuantity>0||pizzaCart[i].largeQuantity||pizzaCart[i].others>0||pizzaCart[i].freshPan>0||pizzaCart[i].cheeseBurst||pizzaCart[i].wheatThinCrust>0)
{
if(i>=0&&i<=7){
printf("Id : %d\n",i);
printf("Item Name : %s\n",itemNames[i]);
if(pizzaCart[i].smallQuantity>0)
printf("Small Size Quantity: %d -> Cost : %d\n",pizzaCart[i].smallQuantity,costOnSize[i].smallCost*pizzaCart[i].smallQuantity);
if(pizzaCart[i].mediumQuantity>0)
printf("Medium Size Quantity: %d -> Cost : %d\n",pizzaCart[i].mediumQuantity,costOnSize[i].mediumCost*pizzaCart[i].mediumQuantity);
if(pizzaCart[i].largeQuantity>0)
printf("Large Size Quantity: %d -> Cost : %d\n",pizzaCart[i].largeQuantity,costOnSize[i].largeCost*pizzaCart[i].largeQuantity);
if(pizzaCart[i].freshPan>0)
printf("Fresh Pan Quantity: %d -> Cost : %d\n",pizzaCart[i].freshPan,costOnSize[i].freshPanCost*pizzaCart[i].freshPan);
if(pizzaCart[i].wheatThinCrust>0)
printf("Wheat Thin Crust Quantity: %d -> Cost : %d\n",pizzaCart[i].wheatThinCrust,costOnSize[i].wheatThinCrustCost*pizzaCart[i].wheatThinCrust);
if(pizzaCart[i].cheeseBurst>0)
printf("Cheese Burst Quantity: %d -> Cost : %d\n",pizzaCart[i].cheeseBurst,costOnSize[i].cheeseBurstCost*pizzaCart[i].cheeseBurst);
totalCost+=pizzaCart[i].smallQuantity*costOnSize[i].smallCost;
totalCost+=pizzaCart[i].mediumQuantity*costOnSize[i].mediumCost;
totalCost+=pizzaCart[i].largeQuantity*costOnSize[i].largeCost;
totalCost+=pizzaCart[i].freshPan*costOnSize[i].freshPanCost;
totalCost+=pizzaCart[i].cheeseBurst*costOnSize[i].cheeseBurstCost;
totalCost+=pizzaCart[i].wheatThinCrust*costOnSize[i].wheatThinCrustCost;
}
else{
printf("Id : %d\n",i);
printf("Item Name : %s\n",itemNames[i]);
printf("Quantity : %d\n",pizzaCart[i].others);
printf("Cost : %d\n",pizzaCart[i].others*sidesCost[i-8]);
totalCost+=(pizzaCart[i].others)*sidesCost[i-8];
}
}
}
printf("-------------------Total Cost : %d-----------------------\n",totalCost);
}