Using Borland Pascal- Making a program to read in names and sales figures from text file and then (amongst other things) find the average of the sales and compare all the sales figures to the average. The problem is, only the last entry in the text file comes out for the average comparison. All other aspects of the program work fine. I believe the problem is in this procedure (the rest of the program can be provided on request, it's kinda long):
Procedure comparison;
begin
For index:= 1 to max do;
begin
compare:=sales[index]-average;
Write (names[index],' ');
If compare>0 then
begin
textcolor (green);
Writeln ('£',compare:4:2);
end
else
begin
textcolor (red);
Writeln ('£',compare:4:2);
end;
readkey;
end;
textcolor (white);
end;