Dev - C++ - Alguien me puede ayudar para que el ciclo me agarre todo? C++

 
Vista:

Alguien me puede ayudar para que el ciclo me agarre todo? C++

Publicado por jorge palermo (4 intervenciones) el 18/09/2019 00:02:06
Buenas, sera que me pueden ayudar para que el el ciclo me agarre todo?
la idea es que el código pueda dar factura y de la opción de facturar otra ves a otra persona, pero cuando llega al punto donde te da la opción de seleccionar para comprar otros productos para la segunda factura se salta esa parte y da la factura y no me deja seleccionar mas nada. Como podria solventar eso?

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
#include <iostream>
#include<ctype.h>
#include<limits>
using namespace std;
 
const float torta=20000;
const float helado=15000;
const float oferta_postre=8000;
const float sopa=15000;
const float arroz_pollo=25000;
const float pasta_bolona=35000;
const float oferta_almuerzo=15000;
const float jarra_jugo=15000;
const float vaso_jugo=5000;
const float jarra_agua=10000;
const float vaso_agua=3000;
float total = 0;
int continuar = 0;
int acum_op1 = 0;
int acum_op2 = 0;
int acum_op3 = 0;
int acum_op4 = 0;
int acum_op5 = 0;
int acum_op6 = 0;
int acum_op7 = 0;
int acum_op8 = 0;
int acum_op9 = 0;
int acum_op10 = 0;
int acum_op11 = 0;
int opcion=0;
int i=0 , j;
void pedido(int op){
	int cantidad = 0;
	cout<<"Ingrese la cantidad a pedir:  "<<endl;
	cin>>cantidad;
	while(cin.fail())
	{
		//Clear the fail state.
		cin.clear();
		//Ignore the rest of the wrong user input, till the end of the line.
		cin.ignore(numeric_limits<streamsize>::max(),\
				   '\n');
		cout<<"ERROR"<<endl<<endl;
		 pedido(op);
 
	}
	switch(op)
	{
		case 1:
			total = total + (sopa * cantidad);
			acum_op1 = acum_op1 + cantidad;
			break;
		case 2:
			total = total + (arroz_pollo * cantidad);
			acum_op2 = acum_op2 + cantidad;
			break;
		case 3:
			total = total + (pasta_bolona * cantidad);
			acum_op3 = acum_op3 + cantidad;
			break;
		case 4:
			total = total + (oferta_almuerzo * cantidad);
			acum_op4 = acum_op4 + cantidad;
			break;
		case 5:
			total = total + (jarra_jugo * cantidad);
			acum_op5 = acum_op5 + cantidad;
			break;
		case 6:
			total = total + (vaso_jugo * cantidad);
			acum_op6 = acum_op6 + cantidad;
			break;
		case 7:
			total = total + (jarra_agua * cantidad);
			acum_op7 = acum_op7 + cantidad;
			break;
		case 8:
			total = total + (vaso_agua * cantidad);
			acum_op8 = acum_op8 + cantidad;
			break;
		case 9:
			total = total + (torta * cantidad);
			acum_op9 = acum_op9 + cantidad;
			break;
		case 10:
			total = total + (helado * cantidad);
			acum_op10 = acum_op10 + cantidad;
			break;
		case 11:
			total = total + (oferta_postre * cantidad);
			acum_op11 = acum_op11 + cantidad;
			break;
		default:
 
			cout<<"Ingreso una opción invalida"<<endl;
 
			break;
	}
}
 
void submenu(int op){
	int plato = 0;
	if(op == 1)
	{
		cout <<"En el almuerzo hay:  "<<endl<<endl;
		cout <<"1) Sopa = 15000 "<<endl;
		cout <<"2) Arroz con Pollo = 25000 "<<endl;
		cout <<"3) Pasta Boloñesa = 35000 "<<endl;
		cout <<"4) OFERTA Especial = 15000 (1 bebida y Arroz con Salsa) "<<endl<<endl;
		cin>>plato;
		while(cin.fail())
		{
			//Clear the fail state.
			cin.clear();
			//Ignore the rest of the wrong user input, till the end of the line.
			cin.ignore(numeric_limits<streamsize>::max(),\
					   '\n');
			cout<<"ERROR"<<endl<<endl;
			void submenu(int op);
		}
		if(plato >= 1 && plato <= 4){
			pedido(plato);
 
		}
		else{
			cout<<"Ingreso una opción invalida"<<endl;
			submenu(op);
		}
	}
	else if(op == 2)
	{
		cout <<"De bebida tenemos:  "<<endl<<endl;
		cout <<"5) Jarra de Jugo = 15000 "<<endl;
		cout <<"6) Vaso de Jugo = 5000 "<<endl;
		cout <<"7) Jarra de Agua = 10000 "<<endl;
		cout <<"8) Vaso de Agua = 3000 "<<endl;
		cin>>plato;
		while(cin.fail())
		{
			//Clear the fail state.
			cin.clear();
			//Ignore the rest of the wrong user input, till the end of the line.
			cin.ignore(numeric_limits<streamsize>::max(),\
					   '\n');
			cout<<"Ingreso una opcion invalida"<<endl<<endl;
			void submenu(int op);
		}
		if(plato >= 5 && plato <= 8){
			pedido(plato);
		}
		else{
			cout<<"Ingreso una opción invalida"<<endl;
			submenu(op);
		}
	}
	else{
		cout <<" De postre hay:  "<<endl<<endl;
		cout <<"9)torta = 20000 "<<endl;
		cout <<"10)helado = 15000 "<<endl;
		cout <<"11)OFERTA ESPECIAL = 8000 (1 cafe y galletas dulces) "<<endl<<endl;
		cin>>plato;
		while(cin.fail())
		{
			//Clear the fail state.
			cin.clear();
			//Ignore the rest of the wrong user input, till the end of the line.
			cin.ignore(numeric_limits<streamsize>::max(),\
					   '\n');
			cout<<"Ingreso una opcion invalida"<<endl<<endl;
			void submenu(int op);
		}
		if(plato >= 9 && plato <= 11){
			pedido(plato);
		}
		else{
			cout<<"Ingreso una opción invalida"<<endl;
			submenu(op);
		}
	}
}
 
 
void menu(){
	cout<<"1) Almuerzo"<<endl;
	cout<<"2) Bebida"<<endl;
	cout<<"3) Postre"<<endl;
	cin>>opcion;
	switch(opcion){
 
		case 1:
			submenu(1);
			break;
		case 2:
			submenu(2);
			break;
		case 3:
			submenu(3);
			break;
	default:
		while(cin.fail())
		{
			//Clear the fail state.
			cin.clear();
			//Ignore the rest of the wrong user input, till the end of the line.
			cin.ignore(numeric_limits<streamsize>::max(),\
					   '\n');
			cout<<"Ingreso una opcion invalida"<<endl<<endl;
 
		}
		cout<<"Ingreso una opción invalida"<<endl;
		menu();
		break;
 
	}
 
	while(continuar != 1 and continuar != 2){
		cout<<"¿Desea pedir algo más? Si=1;No=2"<<endl;
		cin>>continuar;
		while(cin.fail())
		{
			//Clear the fail state.
			cin.clear();
			//Ignore the rest of the wrong user input, till the end of the line.
			cin.ignore(numeric_limits<streamsize>::max(),\
					   '\n');
			cout<<"Ingreso una opcion invalida"<<endl<<endl;
			void submenu(int op);
		}
	}
 
	if(continuar==1){
		continuar=0;
		menu();
	}
	else{
		system("cls");
 
		cout<<"\n*** PEDIDO *** "<<endl<<endl;
 
		if(acum_op1 >0 ){
			cout<<acum_op1<<" Sopa"<<endl<<endl;
		}
		if(acum_op2 >0 ){
			cout<<acum_op2<<" Arroz con Pollo"<<endl<<endl;
		}
		if(acum_op3 >0 ){
			cout<<acum_op3<<" Pasta Boloñesa"<<endl<<endl;
		}
		if(acum_op4 >0 ){
			cout<<acum_op4<<" OFERTA Especial (1 bebida y Arroz con Salsa)"<<endl<<endl;
		}
		if(acum_op5 >0 ){
			cout<<acum_op5<<" Jarra de Jugo"<<endl<<endl;
		}
		if(acum_op6 >0 ){
			cout<<acum_op6<<" Vaso de Jugo"<<endl<<endl;
		}
		if(acum_op7 >0 ){
			cout<<acum_op7<<" Jarra de Agua"<<endl<<endl;
		}
		if(acum_op8 >0 ){
			cout<<acum_op8<<" Vaso de Agua"<<endl<<endl;
		}
		if(acum_op9 >0 ){
			cout<<acum_op9<<" Torta"<<endl<<endl;
		}
		if(acum_op10 >0 ){
			cout<<acum_op10<<" Helado"<<endl<<endl;
		}
		if(acum_op11 >0 ){
			cout<<acum_op11<<" OFERTA ESPECIAL (1 cafe y galletas dulces)"<<endl<<endl;
		}
		cout<<"Total a Pagar:  "<<total<<endl<<endl;
		while(cin.fail())
		{
			//Clear the fail state.
			cin.clear();
			//Ignore the rest of the wrong user input, till the end of the line.
			cin.ignore(numeric_limits<streamsize>::max(),\
					   '\n');
			cout<<"Ingreso una opcion invalida"<<endl<<endl;
			void menu(int op);
		}
	}
}
 
int main(int argc, char *argv[]) {
	cout<<"*** BIENVENIDOS AL RESTAURANTE BONIN ***"<<endl<<endl<<endl;
	cout<<"Cantidad de personas que van a ser atendidas?"<<endl;
	cin>>i;
	cout<<"  ** ¿ QUE DESEA ORDENAR ? ** "<<endl<<endl;
	for(j=0 ; j<=i ; j++){
 
	menu();
 
	system("pause");
	}
	return 0;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder