0

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;

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by Lord Soth
0

Hi, I dont see the problem here.
I would suggest check the followin:
Is max set to the size of sales ?
Does sales contain more the 1 entry ?
What does the readkey procedure do ?
(I code in Dephi so i have to get accustomed to pascal syntax).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.