Pascal/Turbo Pascal - Urgente Ayuda con ejercicios finales pascal

 
Vista:

Urgente Ayuda con ejercicios finales pascal

Publicado por Pedro (4 intervenciones) el 01/04/2013 13:20:35
Hola necesito ayuda urgente con los ejercicios finales de pascal

Codifique un procedimiento (calcula_pedido) que en el registro cero de la cesta actualice todos los valores de forma adecuada. Si lo considera oportuno, puede crear procedimientos para realizar cada uno de los cálculos (calcula_unidades, calcula_precio…).

Recuerde que a partir de la invocación de calcula_pedido el campo en_cesta de la posición cero de la cesta hay un TRUE significa que el pedido está hecho y no se pueden hacer modificaciones en la cesta (estará prohibido añadir, borrar productos o cambiar los datos de un producto).
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

Urgente Ayuda con ejercicios finales pascal

Publicado por ramon (2158 intervenciones) el 01/04/2013 19:27:38
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
{Con la información que me pasas poco puedo hacer pero esto esta en otras consultas a ver
si te sirve sino dame mas datos de lo que quieres y tratare de prepararte un programa de
ejemplo siempre bajo mi criterio de como debería de plantearse.
 
   program CEScom;
  uses
   crt;
  const
     TAMMAXCESTA=3;
 
  Type
    tproducto = record
        nombre : string;
   numunidades : integer;
 precio_unidad : real;
      en_cesta : boolean;
   end;
  tabcesta = array[0..TAMMAXCESTA] of tproducto;
 
  Var
   ini : tabcesta;
   prod : tabcesta;
   cest : tproducto;
 
Procedure Lee_producto(Var produc:tproducto); (*procedimiento de lectura*)
Begin
Write('Nombre del producto: ');
Readln(produc.nombre);
Write('Numero de unidades: ');
Readln(produc.numunidades);
Write('Precio de cada unidad: ');
Readln(produc.precio_unidad);
End;
 
 
Procedure escribre_producto(produc:tproducto);(*procedimiento de lectura*)
begin
Writeln('Nombre: ',produc.nombre);
Writeln('Numero de unidades: ');
Writeln('Precio de cada unidad;: ',produc.precio_unidad);
End;
 
 
 
 
Procedure inicializa_cesta (Var ini:Tabcesta);
 
Var
en_cesta:boolean;
i:integer;
begin
en_cesta:=false;
for i:= 0 to TAMMAXCESTA do
writeln (ini[i].en_cesta);
end;
 
Procedure mostrar_producto( Var prod:tabcesta);
 
Var
i:integer;
begin
for i:=1 to TAMMAXCESTA do
write (prod[i].nombre);
end;
 
 
Procedure mostrar_cesta(cesta_compra:tabcesta);
Var
en_cesta:boolean;
i:integer;
begin
en_cesta:=true;
for i:=1 to TAMMAXCESTA do
write (cesta_compra[i].en_cesta);
end;
 
  Function cuenta_productos(ini : tabcesta) : integer;
  Var
   i : integer;
   c : integer;
  begin
    c := 0;
   for i := 1 To TAMMAXCESTA do
   if ini[i].en_cesta= true then
   c := c + 1;
   cuenta_productos:= c;
 end;
 
 
  Function busca_libre (buslib: tabcesta): integer;
  Var
    i : integer;
    c : integer;
  begin
    c := 0;
   for i := 1 to TAMMAXCESTA do
   if buslib[i].en_cesta = false then
   begin
      c := i;
      break;
   end;
    if c > 0 then
    begin
    end
 else
    begin
     busca_libre := 0;
    end;
  end;
 
  procedure incluir_producto_en_cesta(cest : tabcesta);
  var
    li : integer;
  begin
      li := busca_libre(cest);
      Lee_producto(cest[li]);
  end;
 
  function buscar_producto(nomb : string) : integer;
  var
     s : integer;
     sal : boolean;
  begin
     s := 1;
     sal := false;
     while (s < TAMMAXCESTA) and (sal = false) do
     begin
        if ini[s].nombre = nomb then
        sal := true
      else
        s := s + 1;
     end;
      if sal = true then
      buscar_producto := s
    else
      buscar_producto := 0;
  end;
 
  procedure eliminar_producto_de_cesta;
  var
    pro : string;
    vc : integer;
  begin
     clrscr;
     write('  Entre Nombre del Producto a Eliminar : ');
     readln(pro);
     vc := buscar_producto(pro);
     if vc > 0 then
     ini[vc].en_cesta := false
   else
     writeln('Producto no encontrado');
  end;
 
 
  procedure modificar_producto;
  var
    pro : string;
    vc : integer;
    rr : char;
  begin
     clrscr;
     write('  Entre Nombre del Producto a Eliminar : ');
     readln(pro);
     vc := buscar_producto(pro);
     if vc > 0 then
     begin
        writeln('  Elija Producto a Modificar ');
        writeln;
        writeln(' 1 = Nombre');
        writeln(' 2 = Cantidad');
        writeln(' 3 = Precio');
        writeln(' 4 = Ninguno');
        repeat
 
        until rr in['1','2','3','4'];
     case rr of
   '1' : begin
            write('  Entre Nuevo Nombre : ');
            readln(ini[vc].nombre);
         end;
   '2' : begin
            write('  Entre Nueva Cantidad : ');
            readln(ini[vc].numunidades);
         end;
   '3' : begin
            write('  Entre Nuevo Precio : ');
            readln(ini[vc].precio_unidad);
         end;
     end;
     end
   else
      writeln('Producto no encontrado');
  end;
 
  function calcula_pedido : real;
  var
    num : integer;
    costo : real;
  begin
     costo := 0;
     for num := 1 to TAMMAXCESTA do
     begin
        costo := costo + (prod[num].precio_unidad *
                           prod[num].numunidades);
     end;
      calcula_pedido := costo;
  end;
 
  procedure ponfinal;
  var
    si : char;
  begin
      if prod[0].en_cesta = false then
      begin
      clrscr;
      writeln('Desea Cerrar La Cesta [S/N]');
      repeat
          si := readkey;
      until si in['s','S','n','N'];
      if si in ['s','S'] then
      begin
         prod[0].nombre := 'Fimal cesta';
         prod[0].precio_unidad := calcula_pedido;
         prod[0].numunidades := 1;
         prod[0].en_cesta := true;
      clrscr;
      writeln(' ** ',prod[0].nombre,' ** ');
      writeln('  Precio de Cesta = ',prod[0].precio_unidad);
      writeln('  Estado de Cesta = ',prod[0].en_cesta);
       end;
      end
    else
       begin
          clrscr;
          writeln('La Cesta Esta Cerrada Pulse Tecla [Espaciado]');
          readkey;
       end;
  end;
 
 
  procedure iniciocesta;
  var
    gg : char;
    w : integer;
  begin
       w := 1;
       inicializa_cesta(ini);
     repeat
      clrscr;
   writeln(' ****  Menu Cesta ****');
   writeln;
   writeln(' 1 = A¤adir producto a la cesta');
   writeln(' 2 = Eliminar producto de la cesta');
   writeln(' 3 = Mostrar cesta');
   writeln(' 4 = Modificar producto de la cesta');
   writeln(' 5 = Contar productos de la cesta');
   writeln(' 6 = Pon Final Cesta');
   writeln(' 7 = Salir del programa');
   writeln;
   writeln('<<< Elija Opcion >>>');
   repeat
       gg := readkey;
   until gg in['1','2','3','4','5','6','7'];
     case gg of
   '1' : begin Lee_producto(ini[w]); w := w + 1; end;
   '2' : eliminar_producto_de_cesta;
   '3' : mostrar_cesta(ini);
   '4' : modificar_producto;
   '5' : cuenta_productos(ini);
   '6' : ponfinal;
    end;
    until gg = '7';
  end;
 
begin
    clrscr;
    iniciocesta;
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar