ayuda con case y do-while
Publicado por christopher (4 intervenciones) el 26/12/2020 22:42:45
hola me podrían ayudar con este programa el primero seria que en la parte cuando selecciono lo de Sony y cuando selecciono el case 2 no me aprese y no se por que y también me gustaría saber como le podría hacer para guardar la compra si en caso seleccionan comprar mas cosas .
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
#include <stdlib.h>
#include <windows.h>
#include <iostream>
#include <math.h>
using namespace std;
//PROTOTIPOS DE LAS FUNCIONES
void dibujarCuadro(int x1,int y1,int x2,int y2);
void gotoxy(int x,int y);
//FUNCION PRINCIPAL MAIN
int main(){
system("mode con: cols=80 lines=25"); //SE DEFINE LAS DIMENSIONES DE LA VENTANA DEL PROGRAMA A 80 COLUMNAS Y 25 FILAS
system("COLOR 8f"); //SE DA UN COLOR DE FONDO Y COLOR A LAS LETRAS
dibujarCuadro(0,0,78,24); //SE DIBUJA EL CUADRO PRINCIPAL
dibujarCuadro(1,1,77,3); //SE DIBUJA EL CUADRO DEL TITULO
gotoxy(30,2); cout << "NAVAGAME";
printf ("\n\n\t bienvenido \n");
char NOM[20],DIS,SE,COM ;
int OP , O ;
float AR1,AR2,AR3,AR4,AR5,AR6,AR7,TO,CAN1,CAN2,CAN3,CAN4,CAN5,CAN6,CAN7;
do
{
printf ("\t ¿desea comprar algo en en la tienda? \t 1=si 2=no \t");
fflush( stdin );
scanf( "%s", &SE);
if (SE =='s' )
{
printf("\t seleciona que distribuidor de video juegos decea comprar \n ");
printf ("\t 1.-SONY\n");
printf ("\t 2.-MICROSOFT\n");
printf("\t 3.-NITENDO \n\n");
printf ("\t 4.- computo \n");
scanf("%d",&OP);
switch (OP){ do{
case 1: system("color 1f");
system("cls");
system("mode con: cols=82 lines=36"); //SE DEFINE LAS DIMENSIONES DE LA VENTANA DEL PROGRAMA A 80 COLUMNAS Y 25 FILAS
dibujarCuadro(0,0,80,35); //SE DIBUJA EL CUADRO PRINCIPAL
dibujarCuadro(1,1,77,3); //SE DIBUJA EL CUADRO DEL TITULO
gotoxy(30,2); cout << "NAVAGAME \n";
printf ("\t\n 1-.consola o acesorios \t");
printf ("\t\n 2.-video juegos \n");
scanf ("%d",&O);
switch (O)
case 1 : printf ("\n \t 1.-playstation 5 $13500 \t");
scanf("\t %f",&CAN1);
printf ("\n\t 2.-playstation 4 $12000 \t");
scanf("\t %f",&CAN2);
printf("\n\t 3.-dualshock ps4 $1200 \t");
scanf("\t %f",&CAN3);
printf("\n\t 4.-dualsense ps5 $1350 \t");
scanf("\t %f",&CAN4);
printf ("\n\t 5.-Headset $1000 \t");
scanf("\t %f",&CAN5);
printf ("\n\t 6.-psp $2500 \t");
scanf("\t %f",&CAN6);
printf ("\n\t 7.- psvita $3000 \t");
scanf("\t %f",&CAN7);
AR1=13500;AR2=12000;AR3=1200;AR4=1350;AR5=1000;AR6=2500;AR7=3500;
TO=(AR1*CAN1)+(AR2*CAN2)+(AR3*CAN3)+(AR4*CAN4)+(AR5*CAN5)+(AR6*CAN6)+(AR7*CAN7);
printf("\n su precio a pagar es de: \t %f",TO);
printf("\n 1.- si desea regrsar a la categoria de sony o 2.- regresar al menu principal ");
scanf("%s",&COM);break;
case 2 :
printf ("\n the amazing spiderman $1200 \n ");
scanf ("%f",&CAN1);
printf ("\n grand turismo sport $699 \n ");
scanf ("%f",&CAN2);
printf ("\n the sims 4 $599 \n ");
scanf ("%f",&CAN3);
printf ("\n fifa 21 $1299 \n");
scanf ("%f",&CAN4);
printf ("\n pes 21 $1199 \n");
scanf ("%f",&CAN5);
printf ("\n resident evil 7 $799 \n");
scanf ("%f",&CAN6);
printf ("\n grand the autho 5 $899 \n");
scanf ("%f",&CAN7);
AR1=1200;AR2=699;AR3=599;AR4=1299;AR5=1199;AR6=799;AR7=899;
TO=(AR1*CAN1)+(AR2*CAN2)+(AR3*CAN3)+(AR4*CAN4)+(AR5*CAN5)+(AR6*CAN6)+(AR7*CAN7);break;
}while(COM !='s');
}
}
else (SE ==2);{
exit(-1);}
} while ( SE != 'n');
gotoxy (2,12);
}
//FUNCION GOTOXY
void gotoxy(int x,int y){
HANDLE hcon;
hcon = GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwPos;
dwPos.X = x;
dwPos.Y= y;
SetConsoleCursorPosition(hcon,dwPos);
}
//FUNCION QUE DIBUJA EL CUADRO
void dibujarCuadro(int x1,int y1,int x2,int y2){
int i;
for (i=x1;i<x2;i++){
gotoxy(i,y1); cout << "\304"; //linea horizontal superior
gotoxy(i,y2); cout << "\304"; //linea horizontal inferior
}
for (i=y1;i<y2;i++){
gotoxy(x1,i); cout <<"\263"; //linea vertical izquierda
gotoxy(x2,i); cout <<"\263"; //linea vertical derecha
}
gotoxy(x1,y1); cout<< "\332";
gotoxy(x1,y2); cout<< "\300";
gotoxy(x2,y1); cout<< "\277";
gotoxy(x2,y2); cout<< "\331";
}
Valora esta pregunta


0