-
Notifications
You must be signed in to change notification settings - Fork 0
/
parcial1.pas
73 lines (64 loc) · 1.63 KB
/
parcial1.pas
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
program parcial1;
const corte='ZZZ';
type
cadena=string[20];
venta=record
razon:cadena;
genero:cadena;
nombre:cadena;
precio:integer;
cant:integer;
end;
archivo=file of venta;
procedure leer(var arch:archivo; var reg:venta);
begin
if not eof(arch) then
read(arch,reg)
else
reg.razon:=corte;
end;
procedure informarVentas(var arch:archivo);
var
razon_act,genero_act,nombre_act:cadena;
total,total_genero,total_libro,cant_libro:integer;
reg:venta;
begin
reset(arch);
leer(arch,reg);
total:=0;
while reg.razon <> corte do begin
razon_act:=reg.razon;
writeln('Libreria: ',reg.razon);
total_genero:=0;
while (reg.genero= genero_act) do begin
writeln('Genero: ', reg.genero);
genero_act:=reg.genero;
total_libro:=0;
while (reg.razon=razon_act) and (reg.genero = genero_act) do begin
writeln('Nombre de libro: ',reg.nombre);
nombre_act:=reg.nombre;
total_libro:=reg.precio;
cant_libro:=0;
while (reg.razon=razon_act) and (reg.genero=genero_act) and (reg.nombre=nombre_act) do begin
cant_libro:=cant_libro + reg.cant;
leer(arch,reg);
end;
total_libro:=total_libro*cant_libro;
writeln('Total vendido libro: ',nombre_act, ' : ', total_libro_);
total_genero:=total_genero+ total_libro;
end;
writeln('Monto vendido genero ', genero_act, ': ',total_genero);
total_razon:=total_razon+ total_genero;
end;
writeln('Monto vendido libreria ', razon_act, ': ', total_razon);
total:=total+ total_razon;
end;
writeln('Monto total librerias: ', total);
close(arch);
end;
var
arch:archivo;
begin
assign(arch,'ventas.arch');
informarVentas(arch);
end.