Help me pls on my Program

whats wrong in this sumation ??


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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
#include<iostream.h>

int price1,price2,price3,price4,price5,price6,price7,price8,price9,price10,price11,price12,price13,price14,price15,price16,price17;

const int CPizza =100 ,PPizza =150,BPizza=100,Mpizza=100,MzPizza=150;
const int C=15,R=15,S=15,PAJ=20,AJ=20;
const int BeefB=30,PorkB=20,ChickenB=25,Spa=60,Carb=80;
const int FS=75,MS=50;



void ptotal1(int price1,int ppiece1)
{
int po1=price1*ppiece1;
cout<<"\n Total Amount :"<<po1<<"\n";

return bills(po1);
}


void ptotal2(int price2,int ppiece2)
{
int po2=price2*ppiece2;
cout<<"\n Total Amount :"<<po2<<"\n"; 

return bills(po2);
}


void ptotal3(int price3,int ppiece3)
{
int po3=price3*ppiece3;
cout<<"\n Total Amount :"<<po3<<"\n"; 



return bills(po3);
}


void ptotal4(int price4,int ppiece4)
{
int po4=price4*ppiece4;
cout<<"\n Total Amount :"<<po4<<"\n"; 


return bills(po4);
}


void ptotal5(int price5,int ppiece5)
{
int po5=price5*ppiece5;
cout<<"\n Total Amount :"<<po5<<"\n"; 


return bills(po5);
}



// -- Drinks --

void dtotal1(int price6,int dpiece1)
{
int do1=price6*dpiece1;
cout<<"\n Total Amount :"<<do1<<"\n";


return bills(do1);
}

void dtotal2(int price7,int dpiece2)
{
int do2=price7*dpiece2;
cout<<"\n Total Amount :"<<do2<<"\n";

return bills(do2);
}


void dtotal3(int price8,int dpiece3)
{
int do3=price8*dpiece3;
cout<<"\n Total Amount :"<<do3<<"\n"; 

return bills(do3);
}


void dtotal4(int price9,int dpiece4)
{
int do4=price9*dpiece4;
cout<<"\n Total Amount :"<<do4<<"\n"; 

return bills(do4);
}


void dtotal5(int price10,int dpiece5)
{
int do5=price10*dpiece5;
cout<<"\n Total Amount :"<<do5<<"\n";


return bills(do5);
}




// -- Side Dish --
void sdtotal1(int price11,int sdpiece1)
{
int sdo1=price11*sdpiece1;
cout<<"\n Total Amount :"<<sdo1<<"\n";

return bills(sdo1);
}


void sdtotal2(int price12,int sdpiece2)
{
int sdo2=price12*sdpiece2;
cout<<"\n Total Amount :"<<sdo2<<"\n";

return bills(sdo2);
}


void sdtotal3(int price13,int sdpiece3)
{	
int sdo3=price13*sdpiece3;
cout<<"\n Total Amount :"<<sdo3<<"\n";

return bills(sdo3);
}


void sdtotal4(int price14,int sdpiece4)
{
int sdo4=price14*sdpiece4;
cout<<"\n Total Amount :"<<sdo4<<"\n";

return bills(sdo4);
}


void sdtotal5(int price15,int sdpiece5)
{
int sdo5=price15*sdpiece5;
cout<<"\n Total Amount :"<<sdo5<<"\n";

return bills(sdo5);
}

// -- Salad --
void stotal1(int price16,int spiece1)
{
int so1=price16*spiece1;
cout<<"\n Total Amount :"<<so1<<"\n";

return bills(so1);
}

void stotal2(int price17,int spiece2)
{
int so2=price17*spiece2;
cout<<"\n Total Amount :"<<so2<<"\n";

return bills(so2);
}



int main()
{
cout<<"************************************************************\n";
cout<<"*                     - AE1DA Pizza Store -                *\n";
cout<<"************************************************************\n";
cout<<"*       \2 Pizza \2              *      \2 Drinks \2           *\n";
cout<<"*  1-Cheese Pizza       =P100  *  1 - Coke             =P15*\n";
cout<<"*  2-Pepperoni Pizza    =P150  *  2 - Royal            =P15*\n";
cout<<"*  3-Bacon Pizza        =P100  *  3 - Sprite           =P15*\n";
cout<<"*  4-Mushroom Pizza     =P100  *  4 - Apple Juice      =P20*\n";
cout<<"*  5-Mozzarella Pizza   =P150  *  5 - Pine Apple Juice =P20*\n";
cout<<"************************************************************\n";
cout<<"*    \2 Side Dishes \2           *       \2 Salad \2           *\n";
cout<<"*   1 - Beef Barbeque    =P30  *                           *\n";
cout<<"*   2 - Pork Barbeque    =P20  *  1 - Fruit Salad     =P75 *\n";
cout<<"*   3 - Chicken Barbeque =P25  *                           *\n";
cout<<"*   4 - Spaghetti        =P60  *  2 - Macaroni Salad  =P50 *\n";
cout<<"*   5 - Carbonara        =P80  *                           *\n";
cout<<"************************************************************\n";

// -- Pizza --
cout<<"Would you like order Pizza ? (1.Yes \2 2.No): ";
int pchoice;
cin>>pchoice;

if(pchoice==1)
{
cout<<"\n\2 Enter Code of Pizza Order (\2 1 - 5 \2): ";
int order1;
cin>>order1;
switch (order1)
{
case 1:
cout<<"\3 Cheese Pizza \3\n";
price1=CPizza;
cout<<"How many piece/s ? :";
int ppiece1;
cin>>ppiece1;
ptotal1(price1,ppiece1);goto order2;
break;


case 2:
cout<<"\3 Pepperoni Pizza \3\n";
price2=PPizza;
cout<<"How many piece/s ? :";
int ppiece2;
cin>>ppiece2;
ptotal2(price2,ppiece2);goto order2;
break;


case 3:
cout<<"\3 Bacon Pizza \3\n";
price3=BPizza;
cout<<"How many piece/s ? :";
int ppiece3;
cin>>ppiece3;
ptotal3(price3,ppiece3);goto order2;
break;


case 4:
cout<<"\3 Mushroom Pizza \3\n";
price4=Mpizza;
cout<<"How many piece/s ? :";
int ppiece4;
cin>>ppiece4;
ptotal4(price4,ppiece4);goto order2;
break;


case 5:
cout<<"\3 Mozzarella Pizza \3\n";
price5=MzPizza;
cout<<"How many piece/s ? :";
int ppiece5;
cin>>ppiece5;
ptotal5(price5,ppiece5);goto order2;
break;
}
}


else
{
order2:
cout<<"\n\nWould you like order Drinks ? (1.Yes \2 2.No): ";
int dchoice;
cin>>dchoice;


if(dchoice==1)
{
cout<<"\n\2 Enter Code of Drinks Order (\2 1 - 5 \2): ";
int order2;
cin>>order2;


switch (order2)
{
case 1:
cout<<"\3 Coke \3\n";
price6=C;
cout<<"How many piece/s ? :";
int dpiece1;
cin>>dpiece1;
dtotal1(price6,dpiece1);goto order3;
break;

case 2:
cout<<"\3 Royal \3\n";
price7=R;
cout<<"How many piece/s ? :";
int dpiece2;
cin>>dpiece2;
dtotal2(price7,dpiece2);goto order3;
break;

case 3:
cout<<"\3 Sprite \3\n";
price8=S;
cout<<"How many piece/s ? :";
int dpiece3;
cin>>dpiece3;
dtotal3(price8,dpiece3);goto order3;
break;

case 4:
cout<<"\3 Apple Juice \3\n";
price9=AJ;
cout<<"How many piece/s ? :";
int dpiece4;
cin>>dpiece4;
dtotal4(price9,dpiece4);goto order3;
break;

case 5:
cout<<"\3 Pine Apple Juice \3\n";
price10=PAJ;
cout<<"How many piece/s ? :";
int dpiece5;
cin>>dpiece5;
dtotal5(price10,dpiece5);goto order3;
break;
}

}

}

// -- Side Dish --
order3:
cout<<"\n\nWould you like order Side Dish ? (1.Yes \2 2.No): ";
int sdchoice;
cin>>sdchoice;

if(sdchoice==1)
{
cout<<"\n\2 Enter Code of Side dish Order (\2 1 - 5 \2): ";
int order3;
cin>>order3;
switch(order3)
{
case 1:
cout<<"\3 Beef Barbeque \3\n";
price11=BeefB;
cout<<"How many piece/s ? :";
int sdpiece1;
cin>>sdpiece1;
sdtotal1(price11,sdpiece1);goto order4;

break;
case 2:
cout<<"\3 Pork Barbeque \3\n";
price12=PorkB;
cout<<"How many piece/s ? :";
int sdpiece2;
cin>>sdpiece2;
sdtotal2(price12,sdpiece2);goto order4;
break;

case 3:
cout<<"\3 Chicken Barbeque \3\n";
price13=ChickenB;
cout<<"How many piece/s ? :";
int sdpiece3;
cin>>sdpiece3;
sdtotal3(price13,sdpiece3);goto order4;
break;

case 4:
cout<<"\3 Spaghetti \3\n";
price14=Spa;
cout<<"How many piece/s ? :";
int sdpiece4;
cin>>sdpiece4;
sdtotal4(price14,sdpiece4);goto order4;
break;

case 5:
cout<<"\3 Carbonara \3\n";
price15=Carb;
cout<<"How many piece/s ? :";
int sdpiece5;
cin>>sdpiece5;
sdtotal5(price15,sdpiece5);goto order4;
break;
}

}


// -- Salad --
order4:
cout<<"\n\nWould you like order Salad ? (1.Yes \2 2.No): ";
int schoice;
cin>>schoice;
if(schoice==1)
{
cout<<"\n\2 Enter Code of Salad Order (\2 1 - 2 \2): ";
int order4;
cin>>order4;
switch(order4)
{
case 1:
cout<<"\3 Fruit Salad \3\n";
price16=FS;	
cout<<"How many piece/s ? :";
int spiece1;
cin>>spiece1;
stotal1(price16,spiece1);
break;

case 2:
cout<<"\3 Macaroni Salad \3\n";
price17=MS;
cout<<"How many piece/s ? :";
int spiece2;
cin>>spiece2;
stotal2(price17,spiece2);
break;

}

}



return 0;
}

int bills(int po1,int po2,int po3,int po4,int po5,int do1,int do2,int do3,int do4,int do5,int sdo1,int sdo2,int sdo3,int sdo4,int sdo5,int so1,int so2)
{
int bills=po1+po2+po3+po4+po5 + do1+do2+do3+do4+do5 + sdo1+sdo2+sdo3+sdo4+sdo5 + so1+so2;

cout<<"\n \2 All Total Bills of your Order : "<<bills;

cout<<"\n\nEnter Your Cash";
int cash;
cin>>cash;

}
Last edited on
We're not here to do your homework.

Delete or edit this post and ask a concise question, clearly describing your problem.
Why do you have 17 functions that all do exactly the same thing: multiply two ntegers and show the result?
because when I used only one confused me
What confused you?
closed account (28poGNh0)
Why did you edit your first post?????

however

1 : You need to better indent your code
2 : You have a lot of functions does the same operation(@Keskiverto
17 functions that all do exactly the same thing

3 : Your main contain tens of code you better split it withing functions
4 : You using a lot of repeted code -> solution : functions
5 : In this case you dont need to use goto statements
6 : .....

I tried to simplify your code the result (from 438 to 168) and maybe we still can simlify it !

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
# include <iostream>
using namespace std;

void menu(void)
{
    cout<<"************************************************************\n";
    cout<<"*                     - AE1DA Pizza Store -                *\n";
    cout<<"************************************************************\n";
    cout<<"*       \2 Pizza \2              *      \2 Drinks \2           *\n";
    cout<<"*  1-Cheese Pizza       =P100  *  1 - Coke             =P15*\n";
    cout<<"*  2-Pepperoni Pizza    =P150  *  2 - Royal            =P15*\n";
    cout<<"*  3-Bacon Pizza        =P100  *  3 - Sprite           =P15*\n";
    cout<<"*  4-Mushroom Pizza     =P100  *  4 - Apple Juice      =P20*\n";
    cout<<"*  5-Mozzarella Pizza   =P150  *  5 - Pine Apple Juice =P20*\n";
    cout<<"************************************************************\n";
    cout<<"*    \2 Side Dishes \2           *       \2 Salad \2           *\n";
    cout<<"*   1 - Beef Barbeque    =P30  *                           *\n";
    cout<<"*   2 - Pork Barbeque    =P20  *  1 - Fruit Salad     =P75 *\n";
    cout<<"*   3 - Chicken Barbeque =P25  *                           *\n";
    cout<<"*   4 - Spaghetti        =P60  *  2 - Macaroni Salad  =P50 *\n";
    cout<<"*   5 - Carbonara        =P80  *                           *\n";
    cout<<"************************************************************\n";
}

int ptotal(int price1,int ppiece1)
{
    int po1 = price1*ppiece1;
    cout << "\n Total Amount :" << po1 << "\n";
    return po1;
}

int getAmountTot(const char*szBuffer,int price)
{
    int sum, piece;
    cout << szBuffer << "How many piece/s ? :";
    cin >> piece;
    sum = ptotal(price,piece);
    return sum;
}

int main()
{
    const int CPizza =100 ,PPizza =150,BPizza=100,Mpizza=100,MzPizza=150;
    const int C=15,R=15,S=15,PAJ=20,AJ=20;
    const int BeefB=30,PorkB=20,ChickenB=25,Spa=60,Carb=80;
    const int FS=75,MS=50;

    int amountSum = 0;
    int order;

    menu();

    // -- Pizza --
    cout << "Would you like order Pizza ? (1.Yes \2 2.No): ";
    int choice;
    cin >> choice;

    if(choice==1)
    {
        cout<<"\n\2 Enter Code of Pizza Order (\2 1 - 5 \2): ";

        cin >> order;

        switch (order)
        {
            case 1:
                amountSum += getAmountTot("\3 Cheese Pizza \3\n",CPizza);
            break;
            case 2:
                amountSum += getAmountTot("\3 Pepperoni Pizza \3\n",PPizza);
            break;
            case 3:
                amountSum += getAmountTot("\3 Bacon Pizza \3\n",BPizza);
            break;
            case 4:
                amountSum += getAmountTot("\3 Mushroom Pizza \3\n",Mpizza);
            break;
            case 5:
                amountSum += getAmountTot("\3 Mozzarella Pizza \3\n",MzPizza);
            break;
        }cout << "The amount sum is : " << amountSum << endl;
    }

    // -- Drinks --

    cout << "\n\nWould you like order Drinks ? (1.Yes \2 2.No): ";
    cin >> choice;

    if(choice==1)
    {
        cout<<"\n\2 Enter Code of Drinks Order (\2 1 - 5 \2): ";

        cin >> order;

        switch (order)
        {
            case 1:
                amountSum += getAmountTot("\3 Coke \3\n",C);
            break;
            case 2:
                amountSum += getAmountTot("\3 Royal \3\n",R);
            break;
            case 3:
                amountSum += getAmountTot("\3 Sprite \3\n",S);
            break;
            case 4:
                amountSum += getAmountTot("\3 Apple Juice \3\n",AJ);
            break;
            case 5:
                amountSum += getAmountTot("\3 Pine Apple Juice \3\n",PAJ);
            break;
        }cout << "The amount sum is : " << amountSum << endl;
    }

    // -- Side Dish --
    cout << "\n\nWould you like order Side Dish ? (1.Yes \2 2.No): ";
    cin >> choice;

    if(choice==1)
    {
        cout << "\n\2 Enter Code of Side dish Order (\2 1 - 5 \2): ";

        cin >> order;

        switch(order)
        {
            case 1:
                amountSum += getAmountTot("\3 Beef Barbeque \3\n",BeefB);
            break;
            case 2:
                amountSum += getAmountTot("\3 Pork Barbeque \3\n",PorkB);
            break;
            case 3:
                amountSum += getAmountTot("\3 Chicken Barbeque \3\n",ChickenB);
            break;
            case 4:
                amountSum += getAmountTot("\3 Spaghetti \3\n",Spa);
            break;
            case 5:
                amountSum += getAmountTot("\3 Carbonara \3\n",Carb);
            break;
        }cout << "The amount sum is : " << amountSum << endl;
    }

    // -- Salad --
    cout<<"\n\nWould you like order Salad ? (1.Yes \2 2.No): ";
    cin >> choice;

    if(choice==1)
    {
        cout<<"\n\2 Enter Code of Salad Order (\2 1 - 2 \2): ";

        cin >> order;

        switch(order)
        {
            case 1:
                amountSum += getAmountTot("\3 Fruit Salad \3\n",FS);
            break;
            case 2:
                amountSum += getAmountTot("\3 Macaroni Salad \3\n",MS);
            break;
        }cout << "The amount sum is : " << amountSum << endl;
    }

    return 0;
}


Hope that helps
Thank you very much because I met the deadline of project
^ lol
Topic archived. No new replies allowed.