Comentar paso a paso este programa
Publicado por gabriela (1 intervención) el 02/11/2014 21:35:11
hola, necesito explicar paso a paso este programa que hice tiempo atras.. y no me acuerdo muy bien, aparte en la parte de la opcion dos (ya veran si corren el programa) me da error al insertar un codigo de producto no existente..... SI LO PUEDEN MEJORAR SE LOS AGRADECERIA..
el programa es sobre un supermercado...
gracias de antemano..
PD: falta agregarle algunos clrscr cuando culmine con la accion de las opciones.
el programa es sobre un supermercado...
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
program consecionario;
uses crt;
type
datos = record
cod:string;
nombre:string;
precio:real;
existencia:integer;
condicion:boolean;
end;
var
x,num,i,posicion,consumo:integer;
codigoBuscar:string;
OPCION,OP:CHAR;
cadena:array[1..100] of datos;
function buscar(codigo:string):integer;
begin
for i:=1 to 100 do
begin
IF(codigo=cadena[i].cod)then
buscar:=i;
end;
end;
begin
num:=1;
x:=0;
while(x=0)do
begin
WRITEln('1)Agregar');
WRITEln('2)Consultar');
WRITEln('3)Modificar');
WRITEln('4)Eliminar');
wRITEln('5)Recuperar');
WRITEln('6)Consumo');
WRITEln('Introduzca opcion:');
readln(OPCION);
clrscr;
if(OPCION='1')then
begin
write('Codigo de producto:');
readln(cadena[num].cod);
write('Nombre de producto:');
readln(cadena[num].nombre);
write('Precio de producto:');
readln(cadena[num].precio);
write('Introduzca exitencia:');
readln(cadena[num].existencia);
cadena[num].condicion:=true;
num:=num+1;
clrscr;
end;
if(OPCION='2')then //AQUI ES EL PROBLEMAA
begin
writeln('Codigo del producto:');
readln(codigoBuscar);
posicion:=buscar(codigoBuscar);
if(cadena[posicion].condicion=true)then //si la condicion es verdadera, es decir, si existe el codigo, el lo encontrara.
begin
writeln('cod: ',cadena[posicion].cod);
writeln('nombre: ',cadena[posicion].nombre);
writeln('precio: ',cadena[posicion].precio:7:2);
writeln('existencia: ',cadena[posicion].existencia);
writeln('Pulse ENTER para volver al menu');
readkey;
clrscr;
end
else //sino, arrojara este mensaje.
begin
writeln('El producto que introdujo no existe.');
writeln('Pulse ENTER para volver al menu');
readkey;
clrscr;
end;
end;
if(OPCION='3')then
begin
writeln('introduzca el codigo del producto a buscar');
readln(codigoBuscar);
posicion:=buscar(codigoBuscar);
writeln('1)cambiar el nombre');
writeln('2)cambiar el precio');
writeln('3)cambiar la existencia');
writeln('¿Que desea realizar?');
readln(OP);
if(OP='1')then
begin
WRITE('INTRODUZCA EL nombre:');
READLN(cadena[posicion].nombre);
end;
if(OP='2')then
begin
WRITE('INTRODUZCA EL precio:');
READLN(cadena[posicion].precio);
end;
if(OP='3')then
begin
write('INTRODUZCA la existencia:');
readln(cadena[posicion].existencia);
end;
end;
if(OPCION='4')then
begin
writeln('introduzca el codigo del producto que desea eliminar');
readln(codigoBuscar);
posicion:=buscar(codigoBuscar);
cadena[posicion].condicion:=false;
end;
if(OPCION='5')then
begin
writeln('introduzca el codigo del producto que desea recuperar');
readln(codigoBuscar);
posicion:=buscar(codigoBuscar);
cadena[posicion].condicion:=true;
end;
if(OPCION='6')then
begin
writeln('Codigo de producto a consumir');
readln(codigoBuscar);
posicion:=buscar(codigoBuscar);
writeln('cuantos quieres?');
readln(consumo);
if(cadena[posicion].existencia>=consumo)then
begin
cadena[posicion].existencia:=cadena[posicion].existencia-consumo;
end
else
begin
writeln('En este momento solo existen ',cadena[posicion].existencia,' productos');
writeln('¿Desea realizar consumo?');
end;
end;
end;
end.
gracias de antemano..
PD: falta agregarle algunos clrscr cuando culmine con la accion de las opciones.
Valora esta pregunta


0