Pascal/Turbo Pascal - Consulta corte de control en archivo

 
Vista:
sin imagen de perfil

Consulta corte de control en archivo

Publicado por Horacio (53 intervenciones) el 11/10/2012 21:21:58
Hola a todos,quisiera si alguien me puede ayudar con este ejercicio de corte de control con archivos.

Un comercio de venta de prendas de vestir dispone de los datos en un archivo secuencial a los efectos de controlar los artículos que posee:

Nro. Articulo |Descripción | Precio Unit | Cantidad | Sección

la seccion son 1.Damas 2.Caballeros 3.Niños 4.Bebes

Se desea lo siguiente:
1) Calcular el PRECIO TOTAL por artículo (Precio Unit.*Cantidad).
2) Realizar un listado de los artículos de la Seccion DAMAS cuya Cantidad sea
superior 50 unidades.
3) Calcular el VALOR TOTAL en mercaderías ( PRECIO TOTAL).
4) Generar un Vector con los PRECIOS TOTALES por Sección.
5) Detectar la Sección de Menor PRECIO TOTAL

Desde ya gracias,saludos.
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
sin imagen de perfil

Consulta corte de control en archivo

Publicado por Horacio (53 intervenciones) el 12/10/2012 07:34:31
Les dejo la codificacion que hize si alguno la puede ver y decirme que le falta o que corregir desde ya gracias.

link: http://pastebin.com/w6zpnx8Z
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

Consulta corte de control en archivo

Publicado por ramon (2158 intervenciones) el 12/10/2012 14:43:40
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
{Disculpa no e podido ver tu codificación pero te dejo esto para ver si te ayuda algo suerte}
 
   program articulos;
  uses
     crt;
  const
     tipo : array[1..4] of string[13] = (
     'Damas      : ','Caballeros : ','Ni¤os      : ','Bebes      : ');
  type
 
     prendas = record
          seccion       : integer;
          NArticulo     : integer;
          Descripcion   : string[80];
          PrecioUnit    : real;
          Cantidad      : integer;
        end;
 
  var
    fichero : file of prendas;
    datos   : prendas;
    secc    : integer;
    tec     : char;
    precioarti : real;
    vector : array[1..4,0..0] of real;
 
 procedure entradadatos;
 begin
 repeat
  clrscr;
  with datos do
  begin
  gotoxy(4,3);write('Entre Seccion [1=Damas / 2=Caballeros / 3=Ni¤os / 4=Bebes');
  gotoxy(4,4);write('Cual : ');
  readln(secc);
  if (secc < 1) or (secc > 4) then
  entradadatos;
  seccion := secc;
  gotoxy(4,5);write('N§ Arti+culo : ');
  readln(NArticulo);
  gotoxy(4,6);write('Descripcion : ');
  readln(Descripcion);
  gotoxy(4,7);write('Precio Unidad : ');
  readln(PrecioUnit);
  gotoxy(4,8);write('Cantidad : ');
  readln(Cantidad);
  end;
    assign(fichero,'c:\tp\bin\Basedato.dat');
  {$I-} reset(fichero); {$I+}
  if ioresult <> 0 then
  begin
     rewrite(fichero);
     seek(fichero,0);
     write(fichero,datos);
     close(fichero);
  end
 else
   begin
      seek(fichero,filesize(fichero));
      write(fichero,datos);
      close(fichero);
   end;
   gotoxy(4,12);write('Desea Entrar Mas Datos [S/N]');
   repeat
        tec := upcase(readkey);
   until tec in['N','S'];
  until tec = 'N';
  end;
 
  procedure preciototalarticulo;
  var
    arti : integer;
    arch : longint;
  begin
      clrscr;
      gotoxy(4,3);write('Entre N§ Articulo : ');
      readln(arti);
      assign(fichero,'c:\tp\bin\Basedato.dat');
  {$I-} reset(fichero); {$I+}
  if ioresult <> 0 then
  begin
      writeln('Error de Archivo');
      halt(1);
  end;
     precioarti := 0.0;
     for arch := 0 to filesize(fichero) - 1 do
     begin
        seek(fichero,arch);
        read(fichero,datos);
        if datos.NArticulo = arti then
        precioarti := precioarti + (datos.PrecioUnit * datos.Cantidad);
     end;
     close(fichero);
     writeln('   Precio Total Es : ',precioarti:8:2);
     writeln;
     writeln('   Pulse [Enter]');
     readln;
  end;
 
 procedure listadoarticulosdamas;
 var
   nn : longint;
   arti : integer;
 begin
  clrscr;
  assign(fichero,'c:\tp\bin\Basedato.dat');
  {$I-} reset(fichero); {$I+}
  if ioresult <> 0 then
  begin
      writeln('Error de Archivo');
      halt(1);
  end;
   writeln('seccion   N§ Articulo   Descripcion   Precio Unidad   Cantidad');
   writeln;
   for nn := 0 to filesize(fichero) - 1 do
   begin
       seek(fichero,nn);
       read(fichero,datos);
       if datos.seccion = 1 then
         if datos.cantidad > 50 then
         writeln('  ',datos.seccion,'         ',datos.narticulo,'          ',datos.descripcion,
         '        ',datos.preciounit:8:2,'          ',datos.cantidad);
   end;
     close(fichero);
     writeln;
     writeln('     Pulse [Enter]   ');
     readln;
 end;
 
 procedure valortotaldemercaderia;
 var
   nn : longint;
   total : real;
 begin
  clrscr;
  assign(fichero,'c:\tp\bin\Basedato.dat');
  {$I-} reset(fichero); {$I+}
  if ioresult <> 0 then
  begin
      writeln('Error de Archivo');
      halt(1);
  end;
    total := 0.0;
    for nn := 0 to filesize(fichero) - 1 do
    begin
       seek(fichero,nn);
       read(fichero,datos);
       total := total + datos.preciounit;
    end;
     close(fichero);
     writeln('     El Importe Tatal De Mercaderia Es   ');
     writeln;
     writeln('   ',total:12:2,' xxx');
     writeln;
     writeln('    Pulse [Enter]    ');
     readln;
  end;
 
  procedure generacionvector;
  var
    nn : longint;
    mm, vv, tt : integer;
   begin
    clrscr;
    assign(fichero,'c:\tp\bin\Basedato.dat');
  {$I-} reset(fichero); {$I+}
    if ioresult <> 0 then
     begin
        writeln('Error de Archivo');
        halt(1);
     end;
     vector[1,0] := 0.0;
     vector[2,0] := 0.0;
     vector[3,0] := 0.0;
     vector[4,0] := 0.0;
     for nn := 0 to filesize(fichero) - 1 do
     begin
        seek(fichero,nn);
        read(fichero,datos);
     case datos.seccion of
   1 : begin
          vector[1,0] := vector[1,0] + datos.preciounit;
       end;
   2 : begin
          vector[2,0] := vector[2,0] + datos.preciounit;
       end;
   3 : begin
          vector[3,0] := vector[3,0] + datos.preciounit;
       end;
   4 : begin
          vector[4,0] := vector[4,0] + datos.preciounit;
        end;
      end;
    end;
    close(fichero);
    writeln('   Vector Generado  ');
    writeln;
    for tt := 1 to 4 do
    writeln('  ',tipo[tt],vector[tt,0]:0:2);
    writeln;
  end;
 
  procedure  seccionmenosprecio;
  var
     yy, mn : integer;
     valot : real;
     num : integer;
  begin
     valot := 0;
     num := 0;
         valot := vector[1,0];
         for yy := 2 to 4 do
         begin
         if valot > vector[yy,0] then
         begin
             valot := vector[yy,0];
             num := yy;
           end;
       end;
        writeln('  La Seccion De Menor Precio Es');
        writeln;
        writeln('  ',tipo[num],valot:0:2);
        writeln;
        writeln('  Pulse [Enter]  ');
        readln;
  end;
 
  procedure menu;
  var
     tec : char;
     salir : boolean;
  begin
     salir := false;
   repeat
      clrscr;
      writeln('****** Menu General ******');
      writeln;
      writeln('   1 = Entrada Datos');
      writeln('   2 = Precios articulos');
      writeln('   3 = Listado Articulos Damas');
      writeln('   4 = Valor Mercaderia');
      writeln('   5 = Genera Vector y Seccion Menos Precio');
      writeln('   6 = Salir');
      writeln;
      writeln(' *** Elija Opcion ***');
      repeat
      tec := readkey;
      until tec in[#49..#54];
   case tec of
  #49 : begin clrscr; entradadatos; end;
  #50 : begin clrscr; preciototalarticulo; end;
  #51 : begin clrscr; listadoarticulosdamas; end;
  #52 : begin clrscr; valortotaldemercaderia; end;
  #53 : begin clrscr; generacionvector;
                      seccionmenosprecio;
                     end;
  #54 : salir := true;
  end;
   until salir = true;
  end;
 
 
  begin
      clrscr;
      textcolor(15);
      menu;
  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
sin imagen de perfil

Consulta corte de control en archivo

Publicado por Horacio (53 intervenciones) el 12/10/2012 14:58:15
Gracias Ramon nuevamente,me sirvio para simplificar algunas cosas y corregirlas.saludos
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