Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.