Resto bar shopping in c++

Hey guys, could you guys help me
I just a newbie in coding and my teacher said that my code is too long and I failed the part that should be a calculation for all items that someone ordered to create a receipt. Thank you guys in advance.
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
														

#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;


int main() {
	int Food, Spagheiti, Fries, Burger, Shawarma, Takoyaki, Fish_fiite, Beef_steak, Palabok, Pancit, Pizza, Coke, Royal, Milktea,  Ice_tea, Shake, Salad, Cake, Ice_Creams, Price, Fruit_salad, Macaroni_salad, food1, food2, food3, food4, food5, food6, food7, food8, food9, food10, food11, food12, food13, food14, food15, food16, food17, food18, food19, food20; 
	char Order_again, Yes_or_No, YES_OR_NO;
	bool YesOrNo;
    string Foods;
do{ 
	cout << "Menu" << endl
	     << "Food: " << endl
	     << "1. Spagheiti ...................35 pesos" << endl
	     << "2. Fries........................15 pesos" << endl
	     << "3. Burger.......................30 pesos" << endl
	     << "4. Shawarma.....................30 pesos" << endl
	     << "5. Takoyaki.....................50 pesos" << endl
	     << "6. Fish fiite...................50 pesos" << endl
	     << "7. Beef steak...................60 pesos" << endl
	     << "8. Palabok......................30 pesos" << endl
	     << "9. Pancit.......................30 pesos" << endl
	     << "10. Pizza.......................60 pesos" << endl 
		 << "Drinks:" << endl
	   	 << "11. Coke........................20 pesos" << endl
         << "12. Royal.......................20 pesos" << endl
	     << "13. Milktea.....................50 pesos" << endl
         << "14. Ice-tea.....................30 pesos" << endl
         << "15. Shake.......................20 pesos" << endl		
         << "Dessert: " << endl
		 << "16. Salad.......................60 pesos" << endl	
         << "17. Cake........................55 pesos" << endl	
         << "18. Ice creams..................75 pesos" << endl	
         << "19. Fruit salad.................85 pesos" << endl	
         << "20. Macaroni salad..............65 pesos" << endl
	     << "Input Number According to the type of Food: ";
    cin >> Food;
    cout << "To be comfirmed? if yes type Y and if no type N: " << endl;
    cin >> YES_OR_NO;
    if (YES_OR_NO == 'Y' || YES_OR_NO == 'y') {
   switch (Food)
   {
    case 1:
  	 	Foods = "Spagheiti";
  		Price = 35;
   		cout << "You ordered " << Foods << " for " << Price;
   		Spagheiti = 35;
   		food1 = Price;
   		break;
   	case 2:
  	 	Foods = "Fries";
  		Price = 15;
   		cout << "You ordered " << Foods << " for " << Price;
   		Fries = 15;
   		food1 = Price;
   		break;
   	case 3:
  	 	Foods = "Burger";
  		Price = 30;
   		cout << "You ordered " << Foods << " for " << Price;
   		Burger = 30;
   		food1 = Price;
   		break;
   	case 4:
  	 	Foods = "Shawarma";
  		Price = 30;
   		cout << "You ordered " << Foods << " for " << Price;
   		Shawarma = 30;
   		food1 = Price;
   		break;
   	case 5:
  	 	Foods = "Takoyaki";
  		Price = 50;
   		cout << "You ordered " << Foods << " for " << Price;
   		Takoyaki = 50;
   		food1 = Price;
   		break;
   	case 6:
  	 	Foods = "Fish fiite";
  		Price = 50;
   		cout << "You ordered " << Foods << " for " << Price;
   		Fish_fiite = 50;
   		food1 = Price;
   		break;
   	case 7:
  	 	Foods = "Beef steak";
  		Price = 60;
   		cout << "You ordered " << Foods << " for " << Price;
   		Beef_steak = 60;
   		food1 = Price;
   		break;
   	case 8:
  	 	Foods = "Palabok";
  		Price = 30;
   		cout << "You ordered " << Foods << " for " << Price;
   		Palabok = 30;
   		food1 = Price;
   		break;
   	case 9:
  	 	Foods = "Pancit";
  		Price = 30;
   		cout << "You ordered " << Foods << " for " << Price;
   		Pancit = 30;
   		food1 = Price;
   		break;
   	case 10:
  	 	Foods = "Pizza";
  		Price = 60;
   		cout << "You ordered " << Foods << " for " << Price;
   		Pizza = 60;
   		food1 = Price;
   		break;
   	case 11:
  	 	Foods = "Coke";
  		Price = 20;
   		cout << "You ordered " << Foods << " for " << Price;
   		Coke = 20;
   		food1 = Price;
   		break;
   	case 12:
  	 	Foods = "Royal";
  		Price = 20;
   		cout << "You ordered " << Foods << " for " << Price;
   		Royal = 20;
   		food1 = Price;
   		break;
   	case 13:
  	 	Foods = "Milktea";
  		Price = 50;
   		cout << "You ordered " << Foods << " for " << Price;
   		Milktea = 50;
   		food1 = Price;
   		break;
   	case 14:
  	 	Foods = "Ice-tea";
  		Price = 30;
   		cout << "You ordered " << Foods << " for " << Price;
   		Ice_tea = 30;
   		food1 = Price;
   		break;
   	case 15:
  	 	Foods = "Shake";
  		Price = 20;
   		cout << "You ordered " << Foods << " for " << Price;
   		Shake = 20;
   		food1 = Price;
   		break;
   	case 16:
  	 	Foods = "Salad";
  		Price = 60;
   		cout << "You ordered " << Foods << " for " << Price;
   		Salad = 60;
   		food1 = Price;
   		break;
   	case 17:
  	 	Foods = "Cake";
  		Price = 55;
   		cout << "You ordered " << Foods << " for " << Price;
   		Cake = 55;
   		food1 = Price;
   		break;
   	case 18:
  	 	Foods = "Ice creams";
  		Price = 75;
   		cout << "You ordered " << Foods << " for " << Price;
   		Ice_Creams = 75;
   		food1 = Price;
   		break;
   	case 19:
  	 	Foods = "Fruit salad";
  		Price = 85;
   		cout << "You ordered " << Foods << " for " << Price;
   		Fruit_salad = 85;
   		food1 = Price;
   		break;
   	case 20:
  	 	Foods = "Macaroni salad";
  		Price = 65;
   		cout << "You ordered " << Foods << " for " << Price;
   		Macaroni_salad = 65;
   		food1 = Price;
   		break;
    }
    
}
    
    else if (YES_OR_NO == 'N' || YES_OR_NO == 'n') {
    cout << "You canceled the order." << endl;
    // order again??
	cout << "Do you want to order again? type y if Yes, type n if No: ";
	cin >> Order_again;
}}
    while (Order_again == 'y' || Order_again == 'Y');
 	return 0;
}

And also I feel like I've used so many unnecessary variables in my code.
Last edited on
Well we already told you how to use arrays instead of masses of variable names.
https://www.cplusplus.com/forum/beginner/274568/

A lesson you seem to have learnt here
https://www.cplusplus.com/forum/beginner/274649/

So study previous posts and apply that knowledge.
Have you studied classes/structures yet?

The use of std::vector/arrays would probably be a big help in reducing the number of variables.

Topic archived. No new replies allowed.