const
Workshops: array[1..5] of STRING =
('Foundry','Forge','Metal-working','Assembly','Shipping');
var
Pay:ARRAY[1..5,1..12] of WORD;
Month, Months_bef,Num_of_Quart:BYTE;
Pay_Q:WORD;
i,j,k,l,m:Integer;
F:Text;
Dat_Type,Dt:Char;
BEGIN
REPEAT
Write('Exit (Y/N)? ');
ReadLn(Dt);
If (Dt='N') or (Dt='n') then
begin
Assign(F, 'C:\Data.txt');
Write('New table (Y/N)? ');
ReadLn(Dat_Type);
If (Dat_Type='Y') or (Dat_Type='y') then
begin
Writeln('CAUTION!!! All the previous data will be removed!');
Write('New table (Y/N)? ');
ReadLn(Dat_Type);
end;
If (Dat_Type='Y') or (Dat_Type='y') then
begin
Months_bef:=0;
Month:=1;
ReWrite(F);
Close(F);
end else
begin
ReSet(F);
ReadLn(F,Months_bef);
Month:=Months_bef+1;
For i:=1 to 5 do
For j:=1 to Months_bef do
ReadLn(F, Pay[i,j]);
Close(F);
end;
WriteLn('Month number ',Month);
Writeln('Energy consumtion of workshops:');
For i:=1 to 5 do
begin
Write(Workshops[i]+': ');
ReadLn(Pay[i,Month]);
end;
WriteLn;
Write('Workshops: ');
For j:=1 to 12 do Write(j:5);
WriteLn;
Num_Of_Quart:=Month div 3;
For i:=1 to 5 do
begin
Write(Workshops[i]);
For k:=length(Workshops[i]) to 14 do Write(' ');
For j:=1 to Month do Write(Pay[i,j]:5);
WriteLn;
Write('Quaters_medium:');
For l:=1 to Num_of_Quart do
begin
Pay_Q:=0;
For m:=1 to 3 do
Pay_Q:=Pay_Q+Pay[i,(l-1)*3+m];
Pay_Q:=Pay_Q div 3;
Write(' ',Pay_Q:5,' ');
end;
WriteLn;
end;
WriteLn;
ReWrite(F);
WriteLn(F,Month);
For i:=1 to 5 do
For j:=1 to Month do
WriteLn(F, Pay[i,j]);
Close(F);
end;
UNTIL (Dt='Y') or (Dt='y');
END.