Repeating records. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Repeating records.

misj2lleunmisj2lleun Posts: 4Member
[code]
program kt6_3;



Type Passenger = Record
Last,
First : String;
ID : String[11];
Phone: string;
end;

Luggage = Record
length, width, weight : integer;

end;


var
person: array [1..3] of passenger;
bag: array [1..3] of luggage;
list : text;
i:byte;
k:integer;
begin
for i:= 1 to 3 do

begin
assign(list, 'passenger.txt');
rewrite(list);
writeln('Enter last name, first name and ID [',i,']');
readln(person[i].last, person[i].first, person[i].ID);
writeln('Enter phone number[',i,']');
readln(person[i].phone);
writeln('Enter luggage length, width and weight[',i,']');
readln(bag[i].length, bag[i].width, bag[i].weight);
end;
begin
k:=bad[i].length * bad[i].width;
readln(k);

for i:=1 to 3 do

write(list,
person[i].last, ' , ' ,person[i].first, '(',person[i].ID,
'Telefon:',person[i].phone,
'Pagas:',k,' , ',bag[i].weight,'.');
writeln(list);
end;
close(list);

end.
[/code]

I need to ask user to enter 3 passengers info and save that to 'passenger.txt'. Also, i have to calculate luggage area(lenght*width).
If i run it, it gives me blank txt file and i don't know what to do :( .

Comments

  • _Atex__Atex_ Posts: 163Member
    This should work:[code]program kt6_3;



    Type Passenger = Record
    Last,
    First : String;
    ID : String[11];
    Phone: string;
    end;

    Luggage = Record
    k:integer;
    length, width, weight : integer;
    end;


    var
    person: array [1..3] of passenger;
    bag: array [1..3] of luggage;
    list : text;
    i:byte;

    begin

    for i:= 1 to 3 do
    begin
    writeln('Enter last name, first name and ID [',i,']');
    readln(person[i].last, person[i].first, person[i].ID);
    writeln('Enter phone number[',i,']');
    readln(person[i].phone);
    writeln('Enter luggage length, width and weight[',i,']');
    readln(bag[i].length, bag[i].width, bag[i].weight);
    bag[i].k:=bag[i].length * bag[i].width;
    end;

    assign(list, 'passenger.txt');
    rewrite(list);

    for i:=1 to 3 do
    writeln(list,person[i].last, ' , ' ,person[i].first, '( ',person[i].ID,
    ' Telefon:',person[i].phone,
    ' Pagas:',bag[i].k,' , ',bag[i].weight,'.');

    close(list);

    end.
    [/code]
Sign In or Register to comment.