Pizza Store

create a program for Pizza store that will take orders from 5 variants of pizza, 5 drinks, 5 side Dishes, and 2 types of salad

program must
1. take the order from customer
2. compute the total order
3. add 10%vat to the total order
4. receive cash from the customer
5. compute the change

I've made this program but I dont know wht's wrong with this:
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
1st Program:

#include<iostream.h>
int a1=300,a2=400,a3=500,a4=700,a5=850,b1=10,b2=11,b3=12,b4=14,b5=15,c1=25,c2=35,c3=45,c4=55,c5=65,d1=45,d2=60,x,y,z,sum,cash,sum2,change,vat;

int main()
{
	cout<<"===============================";
	cout<<"             Menu              ";
	cout<<"===============================";
	cout<<"1--Pizza		2--Drinks     ";
	cout<<"  a1-pizza1	  b1-Coke     ";
	cout<<"  a2-pizza2        b2-7up      ";
	cout<<"  a3-pizza3        b3-Sprite   ";
	cout<<"  a4-pizza4        b4-Royal    ";
	cout<<"  a5-pizza5        b5-Mountain Dew";
	cout<<"3--Side Dishes   4--Salad      ";
	cout<<"  c1-side1         d1-salad1   ";
	cout<<"  c2-side2         d2-salad2   ";
	cout<<"  c3-side3                     ";
	cout<<"  c4-side4                     ";
	cout<<"  c5-side5                     "<<endl<<endl;
	loop;
		sum=z+z;
		cout<<"Enter Code:";
		cin>>x;
		cout<<"Piece(s):"
		cin>>y;
		z=x*y;
			if(x=='end') goto comp;
			else goto loop;
				comp;
					vat=sum*.1;
					sum2=vat+sum;
					cout<<"Cash:";
					cin>>cash;
					change=cash-sum2;
cout<<"\t\t ====";
cout<<"Total:"<<sum2;
cout<<"\t\t ===="<<endl;
cout<<"\t\t ====";
cout<<"\t\t ====";
cout<<"Vat:"<<vat;
cout<<"\t\t ====";
cout<<"Cash:"<<cash;
cout<<"\t\t ===="<<endl;
cout<<"\t\t ====";
cout<<"Change:"<<change;
cout<<"\t\t ===="<<endl;

return 0;
}

2nd Program:

#include<iostream.h>
int x,y,z,prod,sum,total,sum1,cash,change,total_sale;

int main()
{
	cout<<"===============================";
	cout<<"             Menu              ";
	cout<<"===============================";
	cout<<"1--Pizza		2--Drinks     ";
	cout<<"  a1-pizza1	  b1-Coke     ";
	cout<<"  a2-pizza2        b2-7up      ";
	cout<<"  a3-pizza3        b3-Sprite   ";
	cout<<"  a4-pizza4        b4-Royal    ";
	cout<<"  a5-pizza5        b5-Mountain Dew";
	cout<<"3--Side Dishes   4--Salad      ";
	cout<<"  c1-side1         d1-salad1   ";
	cout<<"  c2-side2         d2-salad2   ";
	cout<<"  c3-side3                     ";
	cout<<"  c4-side4         0--End of Picking";
	cout<<"  c5-side5                     "<<endl<<endl;
loop;
cout<<"Enter Code:";
cin>>y;
	switch(y)
	{
		case 1:
		cout<<"Enter your Order:";
		cin>>x;
		cout<<"Piece(s):";
		cin>>z;
			if(x=='a1')
			{
				prod=300*z;
				goto computation;
			}
			else if(x=='a2')
			{
				prod=400*z;
				goto computation;
			}
			else if(x=='a3')
			{
				prod=500*z;
				goto computation;
			}
			else if(x=='a4')
			{
				prod=700*z;
				goto computation;
			}
			else if(x=='a5')
			{
				prod=850*z;
				goto computation;
			}
			else goto loop;
			break;
		case 2:
			if(x=='b1')
			{
				prod=10*z;
				goto computation1;
			}
			else if(x=='b2')
			{
				prod=11*z;
				goto computation1;
			}
			else if(x=='b3')
			{
				prod=12*z;
				goto computation1;
			}
			else if(x=='b4')
			{
				prod=14*z;
				goto computation1;
			}
			else if(x=='b5')
			{
				prod=15*z;
				goto computation1;
			}
			else goto loop;
			break;
		case 3:
			if(x=='c1')
			{
				prod=25*z;
				goto computation3;
			}
			else if(x=='c2')
			{
				prod=35*z;
				goto computation3;
			}
			else if(x=='c3')
			{
				prod=45*z;
				goto computation3;
			}
			else if(x=='c4')
			{
				prod=55*z;
				goto computation3;
			}
			else if(x=='c5')
			{
				prod=65*z;
				goto computation3;
			}
			else goto loop;
			break;
		case 4:
			if(x=='d1')
			{
				prod=45*z;
				goto computation4;
			}
			else if(x=='d2')
			{
				prod=60*z;
				goto computation4;
			}
			else goto loop;
			break;
		default goto total_comp;
	}

computation;
sum=prod+0;
goto loop;

computation1;
sum1=prod+0;
goto loop;

computation2;
sum2=prod+0;
goto loop;

computation3;
sum3=prod+0;
goto loop;

computation4;
sum4=prod+0;
goto loop;

total_comp;
total=sum+sum1+sum2+sum3+sum4;
vat=total*.1;
total_sale=total+vat;
cout<<"\t\t ====";
cout<<"Total:"<<total_sale;
cout<<"\t\t ===="<<endl;
cout<<"\t\t ====";
cout<<"Vat:"<<vat;
cout<<"\t\t ===="<<endl
cout<<"\t\t ====";
cout<<"Cash:"<<cash;
cout<<"\t\t ===="<<endl;
cout<<"\t\t ====";
cout<<"Change:"<<change;
cout<<"\t\t ===="<<endl;

return 0;
}

3rd Program:

#include<iostream.h>
int a1=300,a2=400,a3=500,a4=700,a5=850,b1=10,b2=11,b3=12,b4=14,b5=15,c1=25,c2=35,c3=45,c4=55,c5=65,d1=45,d2=60,x,y,z,sum,cash,sum2,change,vat;

int main()
{
	cout<<"===============================";
	cout<<"             Menu              ";
	cout<<"===============================";
	cout<<"1--Pizza		2--Drinks     ";
	cout<<"  a1-pizza1	  b1-Coke     ";
	cout<<"  a2-pizza2        b2-7up      ";
	cout<<"  a3-pizza3        b3-Sprite   ";
	cout<<"  a4-pizza4        b4-Royal    ";
	cout<<"  a5-pizza5        b5-Mountain Dew";
	cout<<"3--Side Dishes   4--Salad      ";
	cout<<"  c1-side1         d1-salad1   ";
	cout<<"  c2-side2         d2-salad2   ";
	cout<<"  c3-side3                     ";
	cout<<"  c4-side4                     ";
	cout<<"  c5-side5                     "<<endl<<endl;
	loop;
		sum=sum1+z;
		cout<<"Enter Code:";
		cin>>x;
		cout<<"Piece(s):"
		cin>>y;
		z=x*y;
		sum1=z+0;
			if(x=='end') goto comp;
			else goto loop;
				comp;
					vat=sum*.1;
					sum2=vat+sum;
					cout<<"Cash:";
					cin>>cash;
					change=cash-sum2;
cout<<"\t\t ====";
cout<<"Total:"<<sum2;
cout<<"\t\t ===="<<endl;
cout<<"\t\t ====";
cout<<"\t\t ====";
cout<<"Vat:"<<vat;
cout<<"\t\t ====";
cout<<"Cash:"<<cash;
cout<<"\t\t ===="<<endl;
cout<<"\t\t ====";
cout<<"Change:"<<change;
cout<<"\t\t ===="<<endl;

return 0;
}


I dont knw whats wrong with of these programs I've made so pls help me !!!
The problem is when i order again it no longer add the amount of what was previously ordered.. Thank You in advance ....
Holy spaghetti code and gratuitous global variables, Batman!
1. Don't use globals. Unless it's necessary for some reason in the project, don't do it.

2. Don't use goto. Using goto can lead to nothing but trouble (especially when it comes to debugging a problem) and is just sloppy programming. Use loops and functions instead to accomplish the same thing in a much more readable and easy to decipher format.

3. If you are using the same few lines over and over, this dictates that a function would be much more useful (and reusable) than tons of lines of code.

4. If you haven't gone over functions in your class yet, at least use loops to make this more reasonable.

Please rewrite this without any gotos and then come back if you need more help.
what does global means ?
Can you help me in making that program ? i dnt knw what should i do .... can anyone pls ?

how can I add the amount that was previously ordered on the the next order ?
Last edited on
Global variables are the ones you have declared underneath #include<iostream.h> (you should just use #include<iostream>). Declaring them within the main function would make them local and since you have no reason for global variables, it would be best to declare them there instead.

"Allyourtext\n" for a new line is better to use than "Allyourtext" << endl. Although both methods give a new line, endl flushes the stream too and can affect performance. It might not matter in this project, but later on if you get time critical projects... ;)

Are you allowed to use functions and strings in making this program? i.e. Have you covered them in class?
Last edited on
If you need those variables to not change, you can consider the following three options:

Method 1:
1
2
3
4
5
6
7
8
9
int main(void)
{
        const int ....;
        const int ....;

        ..
        ..
        return 0;
}

You'll note that I only put one on each line. That improves readability.

Method 2:
1
2
3
4
5
6
7
8
int main(void)
{
        const int[] name = {x(0),x(1),..,x(n-1),x(n)};

        ..
        ..
        return 0;
}


Method 3:
1
2
3
4
5
6
7
header.h:

#define VAR1 x
#define VAR2 y
#define VAR3 z
..
..

1
2
3
4
5
6
7
8
9
10
11
source.cpp:

#include <iostream>
#include "header.h"

int main(void)
{
        ..
        ..
        return 0;
}


For the rest of the variables (the ones that do change), you should declare them with local scope like method 1, but without the const keyword.
what about this one ??? it says
Line 9: error: multi-character character constant
Line 9: error: multi-character character constant
Line 9: error: multi-character character constant
Line 9: error: multi-character character constant
Line 9: error: multi-character character constant
Line 9: error: multi-character character constant
Line 9: error: multi-character character constant
Line 9: error: multi-character character constant
Line 10: error: multi-character character constant
Line 10: error: multi-character character constant
Line 10: error: multi-character character constant
Line 10: error: multi-character character constant
Line 10: error: multi-character character constant
Line 10: error: multi-character character constant
Line 10: error: multi-character character constant
In function 'int main()':
Line 34: error: expected ';' before ':' token
compilation terminated due to -Wfatal-errors.



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
#include<iostream>

int a1=300,a2=400,a3=500,a4=700,a5=850;
int b1=10,b2=11,b3=12,b4=14,b5=15;
int c1=25,c2=35,c3=45,c4=55,c5=65;
int d1=45,d2=60;
int o1,o2,o3,o4,o5,o6,o7,o8,o9,o10,o11,o12,o13,o14,o15,o16,o17;
int p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17;
int prod1,prod2,prod3,prod4,prod5,prod6,prod7,prod8,prod9,prod10,prod11,prod12,prod13,prod14,prod15,prod16,prod17;
int sum,vat,total,cash,change;

int main()
{
	cout<<"\t\t===============================";
	cout<<"\t\t\t             Menu              ";
	cout<<"\t\t===============================";
	cout<<"\t\t1--Pizza\t\t2--Drinks\n";
	cout<<"\t\t\ta1-pizza1\t\t\tb1-Coke\n";
	cout<<"\t\t\ta2-pizza2\t\t\tb2-7up\n";
	cout<<"\t\t\ta3-pizza3\t\t\tb3-Sprite\n";
	cout<<"\t\t\ta4-pizza4\t\t\tb4-Royal\n";
	cout<<"\t\t\ta5-pizza5\t\t\tb5-Mountain Dew\n";
	cout<<"\t\t3--Side Dishes\t\t4--Salad\n";
	cout<<"\t\t\tc1-side1\t\t\td1-salad1\n";
	cout<<"\t\t\tc2-side2\t\t\td2-salad2\n";
	cout<<"\t\t\tc3-side3\n";
	cout<<"\t\t\tc4-side4\n";
	cout<<"\t\t\tc5-side5"<<endl<<endl;

	cout<<"Enter Your Order:";
	cin>>o1;
	cout<<"Piece(s):";
	cin>>p1;
	prod1=o1*p1;
	cout<<"Enter Your Order:";
	cin>>o2;
	cout<<"Piece(s):";
	cin>>p2;
	prod2=o2*p2;
	 if(o2=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o3;
	cout<<"Piece(s):";
	cin>>p3;
	prod3=o3*p3;
	}
	 if(o3=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o4;
	cout<<"Piece(s):";
	cin>>p4;
	prod4=o4*p4;
	}
	 if(o4=='end') goto comp:
	 else
	{	
	cout<<"Enter Your Order:";
	cin>>o5;
	cout<<"Piece(s):";
	cin>>p5;
	prod5=o5*p5;
	}
	 if(o5=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o6;
	cout<<"Piece(s):";
	cin>>p6;
	prod6=o6*p6;
	}
	 if(o6=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o7;
	cout<<"Piece(s):";
	cin>>p7;
	prod7=o7*p7;
	}
	 if(o7=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o8;
	cout<<"Piece(s):";
	cin>>p8;
	prod8=o8*p8;
	}
	 if(o8=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o9;
	cout<<"Piece(s):";
	cin>>p9;
	prod9=o9*p9;
	}
	 if(o9=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o10;
	cout<<"Piece(s):";
	cin>>p10;
	prod10=o10*p10;
	}
	 if(o10=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o11;
	cout<<"Piece(s):";
	cin>>p11;
	prod11=o11*p11;
	}
	 if(o11=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o12;
	cout<<"Piece(s):";
	cin>>p12;
	prod12=o12*p12;
	}
	 if(o12=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o13;
	cout<<"Piece(s):";
	cin>>p13;
	prod13=o13*p13;
	}
	 if(o13=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o14;
	cout<<"Piece(s):";
	cin>>p14;
	prod14=o14*p14;
	}
	 if(o14=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o15;
	cout<<"Piece(s):";
	cin>>p15;
	prod15=o15*p15;
	}
	 if(o15=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o16;
	cout<<"Piece(s):";
	cin>>p16;
	prod16=o16*p16;
	}
	 if(o16=='end') goto comp:
	 else
	{
	cout<<"Enter Your Order:";
	cin>>o17;
	cout<<"Piece(s):";
	cin>>p17;
	prod17=o17*p17;
	}
comp:
sum=prod1+prod2+prod3+prod4+prod5+prod6+prod7+prod8+prod8+prod10+prod11+prod12+prod13+prod14+prod15+prod16+prod17;
vat=sum*.1;
total=sum+vat;
cout<<"Cash:";
cin>>cash;
change=cash-total;
cout<<"\t\t    ====="<<endl;
cout<<"\t\tSum:"<<sum<<endl;
cout<<"\t\t    ====="<<endl<<endl;
cout<<"\t\t    ====="<<endl;
cout<<"\t\tVat:"<<vat<<endl;
cout<<"\t\t    ====="<<endl<<endl;
cout<<"\t\t    ====="<<endl;
cout<<"\t\tTotal:"<<vat<<endl;
cout<<"\t\t    ====="<<endl<<endl;
cout<<"\t\t    ====="<<endl;
cout<<"\t\tCash:"<<cash;
cout<<"\t\t    ====="<<endl<<endl;
cout<<"\t\t    ====="<<endl;
cout<<"\t\tChange:"<<change;
cout<<"\t\t    ====="<<endl<<endl;

return 0;
}


i need to make my project as soon as possible so pls help me ..... im tired thinking what program should I do to make it correct ..... T.T

i cnt stop using goto coz i dnt know what will i do ... so pls help me ..... credit to all ..... T.T
Holy crap. Okay, look at the following:

Iteration structures in here:
http://www.cplusplus.com/doc/tutorial/control/

Scope in here:
http://www.cplusplus.com/doc/tutorial/variables/

This entire article:
http://www.cplusplus.com/doc/tutorial/arrays/

And these:
http://www.cplusplus.com/doc/tutorial/functions/
http://www.cplusplus.com/doc/tutorial/functions2/

There is way too much in that homework spam up there for us to really help you with unless we literally do it for you, and I'm not up for doing that right now.
I'm not that good with pointers so can someone clean up my code if there's anything wrong?

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

void show_menu()
{
    cout << "Here's our menu: \n";
    cout << "Pizzas: \t Drinks: \n";
    cout << "\t Pizza_1 \t Drink_1 \n";
    cout << "\t Pizza_2 \t Drink_2 \n";
    cout << "\t Pizza_3 \t Drink_3 \n";
    cout << "\t Pizza_4 \t Drink_4 \n";
    cout << "\t Pizza_5 \t Drink_5 \n";
    cout << "Side Dishes: \t Salads: \n";
    cout << "\t Side_1 \t Salad_1 \n";
    cout << "\t Side_2 \t Salad_2 \n";
    cout << "\t Side_3 \n";
    cout << "\t Side_4 \n";
    cout << "\t Side_5 \n";
}

int choose_pizza(int pchoice)
{
    for(;;)
    {
        cout << "What pizza would you like? [1-5]: \n";
        cin >> pchoice;
        if(1 <= pchoice && pchoice <= 5)
        {
            break;
        }
        else
        {
            cout << "Please enter 1 - 5\n";
        }
    }
    return pchoice;
}

int choose_drink(int dchoice)
{
    for(;;)
    {
        cout << "What drink would you like? [1-5]: \n";
        cin >> dchoice;
        if(1 <= dchoice && dchoice <= 5)
        {
            break;
        }
        else
        {
            cout << "Please enter 1 - 5\n";
        }
    }
    return dchoice;
}

int choose_side(int cchoice)
{
    for(;;)
    {
        cout << "What side dish would you like? [1-5]: \n";
        cin >> cchoice;
        if(1 <= cchoice && cchoice <= 5)
        {
            break;
        }
        else
        {
            cout << "Please enter 1 - 5\n";
        }
    }
    return cchoice;
}

int choose_salad(int schoice)
{
    for(;;)
    {
        cout << "What salad would you like? [1-2]: \n";
        cin >> schoice;
        if(1 <= schoice && schoice <= 2)
        {
            break;
        }
        else
        {
            cout << "Please enter 1 - 2\n";
        }
    }
    return schoice;
}

void show_choices(char cpizza, char cdrink, char csdish, char csalad, int * pchoice, int * dchoice, int * cchoice, int * schoice)
{
     cout << "Would you like a pizza? (Y/N): \n";
        cin >> cpizza;
        switch(cpizza)
        {
            case 'y':
            case 'Y':
                *pchoice = choose_pizza(*pchoice);
                break;
            case 'n':
            case 'N':
                break;
            default:
                cout << "No answer? OK...\n";
        }
        cout << "Would you like a drink? (Y/N): \n";
        cin >> cdrink;
        switch(cdrink)
        {
            case 'y':
            case 'Y':
                *dchoice = choose_drink(*dchoice);
                break;
            case 'n':
            case 'N':
                break;
            default:
                cout << "No answer? OK...\n";
        }
        cout << "Would you like a side dish? (Y/N): \n";
        cin >> csdish;
        switch(csdish)
        {
            case 'y':
            case 'Y':
                *cchoice = choose_side(*cchoice);
                break;
            case 'n':
            case 'N':
                break;
            default:
                cout << "No answer? OK...\n";
        }
        cout << "Would you like a salad? (Y/N): \n";
        cin >> csalad;
        switch(csalad)
        {
            case 'y':
            case 'Y':
                *schoice = choose_salad(*schoice);
                break;
            case 'n':
            case 'N':
                break;
            default:
                cout << "No answer? OK...\n";
        }
}

double calculate(double total, double sub_total, int pchoice, int dchoice, int cchoice, int schoice)
{
    switch(pchoice)
    {
        case 1:
            sub_total += 3;
            break;
        case 2:
            sub_total += 4;
            break;
        case 3:
            sub_total += 5;
            break;
        case 4:
            sub_total += 7;
            break;
        case 5:
            sub_total += 8.5;
            break;
    }
    switch(dchoice)
    {
        case 1:
            sub_total += .1;
            break;
        case 2:
            sub_total += .11;
            break;
        case 3:
            sub_total += .12;
            break;
        case 4:
            sub_total += .14;
            break;
        case 5:
            sub_total += .15;
            break;
    }
    switch(cchoice)
    {
        case 1:
            sub_total += .25;
            break;
        case 2:
            sub_total += .35;
            break;
        case 3:
            sub_total += .45;
            break;
        case 4:
            sub_total += .55;
            break;
        case 5:
            sub_total += .65;
            break;
    }
    switch(schoice)
    {
        case 1:
            sub_total += .45;
            break;
        case 2:
            sub_total += .60;
            break;
    }
    total = sub_total * .1 + sub_total;
    return total;
}

void show_receipt(double total)
{
    cout << "Your total is: $" << total << "\n";
}
int main(int nNumberofArgs,char* pszArgs[])
{
    char cpizza, cdrink, csdish, csalad, order;
    int pchoice = 0, dchoice = 0, cchoice = 0, schoice = 0;
    double sub_total = 0, total = 0;
    int * ppointer = &pchoice;
    int * dpointer = &dchoice;
    int * cpointer = &cchoice;
    int * spointer = &schoice;

    for(;;)
    {
        show_menu();
        show_choices(cpizza, cdrink, csdish, csalad, ppointer, dpointer, cpointer, spointer);
        total = calculate(total, sub_total, pchoice, dchoice, cchoice, schoice);
        show_receipt(total);
        cout << "Would you like to order again? (Y/N): \n";
        cin >> order;
        switch(order)
        {
            case 'y':
            case 'Y':
                break;
            case 'n':
            case 'N':
                system("PAUSE");
                return 0;
            default:
                break;
        }
    }
}
void show_choices(char cpizza, char cdrink, char csdish, char csalad, int * pchoice, int * dchoice, int * cchoice, int * schoice)
Look through this line and the function that's under it. If you have any variables that aren't used in the function, don't pass them around. It makes your overhead higher, but more importantly for you, it will tend to confuse people that are trying to read the code, including yourself.

1
2
3
4
    int * ppointer = &pchoice;
    int * dpointer = &dchoice;
    int * cpointer = &cchoice;
    int * spointer = &schoice;

These are decent, but you really need to make them more descriptive. A huge part of programming is re-reading your code, and having variable (or pointer) names that don't tell you what they're supposed to do just with their name is not going to help you debug.

int choose_pizza(int pchoice)
All of the functions like this don't need a variable passed to them. Just declare a variable in local scope. It'll make things cleaner, and you can even name the whole lot of them tmp, since they will never interact with each other. That will make it so that these lines:
*pchoice = choose_pizza(*pchoice);
don't actually need to have a variable passed, and so you'll lose the complexity of trying to deal with that pointer at least.

int main(int nNumberofArgs,char* pszArgs[])
You don't have to, if you don't want to, but normally these variables are actually named argc and argv, respectively.
Topic archived. No new replies allowed.