Uses crt;
Const
Days:Array[1..7] of String = ('monday','tuesday','wednesday','thursday',
'friday','saturday','sunday');
Var
f:text;
Num_of_Days,Orders_per_Day_Sum,Orders_Average:Array[1..7] of Word;
day_1,i,Max:Word;
j,N_ord,k:Byte;
S:String[5];
BEGIN
clrscr;
Writeln('Enter the day of January, 1st (1-7): 1 - monday');
WriteLn(' 2 - tuesday');
WriteLn(' 3 - wednesday');
WriteLn(' 4 - thursday');
WriteLn(' 5 - friday');
WriteLn(' 6 - saturday');
Write(' 7 - sunday ');
ReadLn(day_1);
Randomize;
assign(f,'C:\data.txt');
ReWrite(f);
For i:=1 to 365 do
begin
If i<32 then
begin
if i<10 then write(f,'0',i,'.01 ') else write(f,i,'.01 ');
end else
If i<60 then
begin
if i-31<10 then write(f,'0',i-31,'.02 ') else write(f,i-31,'.02 ');
end else
If i<91 then
begin
if i-59<10 then write(f,'0',i-59,'.03 ') else write(f,i-59,'.03 ');
end else
If i<121 then
begin
if i-90<10 then write(f,'0',i-90,'.04 ') else write(f,i-90,'.04 ');
end else
If i<152 then
begin
if i-120<10 then write(f,'0',i-120,'.05 ') else write(f,i-120,'.05 ');
end else
If i<182 then
begin
if i-151<10 then write(f,'0',i-151,'.06 ') else write(f,i-151,'.06 ');
end else
If i<213 then
begin
if i-181<10 then write(f,'0',i-181,'.07 ') else write(f,i-181,'.07 ');
end else
If i<244 then
begin
if i-212<10 then write(f,'0',i-212,'.08 ') else write(f,i-212,'.08 ');
end else
If i<274 then
begin
if i-243<10 then write(f,'0',i-243,'.09 ') else write(f,i-243,'.09 ');
end else
If i<305 then
begin
if i-273<10 then write(f,'0',i-273,'.10 ') else write(f,i-273,'.10 ');
end else
If i<335 then
begin
if i-304<10 then write(f,'0',i-304,'.11 ') else write(f,i-304,'.11 ');
end else
begin
if i-334<10 then write(f,'0',i-334,'.12 ') else write(f,i-334,'.12 ');
end;
If ((day_1+i-1) mod 7)=0 then Write(f,'7')
else Write(f,(day_1+i-1) mod 7);
WriteLn(f,' ',Random(10));
end;
Close(f);
For j:=1 to 7 do
begin
Num_of_Days[j]:=0;
Orders_per_Day_Sum[j]:=0;
end;
Reset(f);
For i:=1 to 365 do
begin
ReadLn(f,S,j,N_ord);
Inc(Num_of_Days[j]);
Orders_per_Day_Sum[j]:=Orders_per_Day_Sum[j]+N_ord;
end;
close(f);
For j:=1 to 7 do
Orders_Average[j]:=Round(Orders_per_Day_Sum[j]/Num_of_Days[j]);
WriteLn('Orders per Days:');
WriteLn(' Day Whole Averaged');
For j:=1 to 7 do
begin
Write(Days[j]);
for k:=length(Days[j]) to 9 do Write(' ');
WriteLn(Orders_per_Day_Sum[j]:8,Orders_Average[j]:8);
end;
WriteLn;
Max:=0;
For j:=1 to 7 do
if Orders_Average[j]>Max then Max:=Orders_Average[j];
WriteLn('Most popular days (',Max,' orders per day) are:');
For j:=1 to 7 do
if Orders_Average[j]=Max then WriteLn(Days[j]);
ReadLn;
end.