my code can't seem to find the maximum price.
program Mobile;
uses winCrt;
type
Mobilephone=record
brand:integer;
model:String;
price:real;
end;
var
hp:array[1..100] of Mobilephone;
count,m,MobileNum:integer;
max:real;
PROCEDURE read_data(var newMobile:Mobilephone);
begin
writeln('Brand:(1:Samsung 2:iPhone 3:Nokia)');
readln(newMobile.brand);
writeln('Model:');
readln(newMobile.model);
writeln('Price:');
readln(newMobile.price);
end;
PROCEDURE displayexp(var exp:Mobilephone);
begin
if(exp.price>max) then
begin
writeln('THE MOST EXPENSIVE HP:');
writeln('Brand: ',exp.brand);
writeln('Model: ',exp.model);
writeln('Price: ',exp.price:5:2);
end;
end;
PROCEDURE displaySamsung(var sam:Mobilephone);
begin
if(sam.brand=1) then
begin
writeln('Samsung models: ',sam.model);
writeln('Total number: ',count);
end;
end;
Begin
writeln('Enter number of mobile phones: ');
readln(MobileNum);
writeln;
For m := 1 to MobileNum do
begin
read_data(hp[m]);
writeln;
if(hp[m].brand=1) then
begin
count:=count+1;
end;
end;
displayexp(hp[m]);
writeln;
writeln('SAMSUNG:');
for m:=1 to MobileNum do
begin
displaySamsung(hp[m]);
end;
delay(10000);
end.