program HierRec; {Input a student record, compute GPA, output the record.} type IDType = 1..2500; String30 = String[30]; AddressType = record Line1 : String30; Line2 : String30 end; PhoneType = String30; PersonInfoType = record Address : AddressType; {a record type} Phone : PhoneType; end; GradesType = 'A'..'F'; StuRecType = record ID : IDType; Name : String30; PersInfo : PersonInfoType; {this is a record type} Grade : GradesType; end; var St1, St2 : StuRecType; procedure ReadPersonInfo ( var FPersInfo : PersonInfoType); {pre : none post : data in FPersInfo} begin WriteLn ('Input a two-line address, followed by a phone number'); ReadLn(FPersInfo.Address.Line1); ReadLn(FPersInfo.Address.Line2); ReadLn(FPersInfo.Phone); WriteLn end;{ReadPersonInfo} procedure ReadStu (var FStu {output} : StuRecType); { Reads one student record into FStu. Pre : None Post: Data are read into record FStu. } begin {ReadEmployee} with FStu do begin Write ('ID> '); ReadLn (ID); Write ('Name> '); ReadLn (Name); ReadPersonInfo (PersInfo); Write ('Grade in a completed course> '); ReadLn(Grade); end {with} end; {ReadStu} procedure WriteStu( FStu {input} : StuRecType ); begin with FStu do begin Write ('ID = ', ID :4); WriteLn (' Name: ', Name); with PersInfo do begin with Address do begin WriteLn (' Address: ', Line1); WriteLn (' ', Line2); end;{with FStu.PersInfo.Address} WriteLn (' Phone: ', Phone); Write (' Grade: ', Grade :2); end {with FStu.PersInfo} end; {with FStu} WriteLn end; {ReadStu} begin{main} ReadStu(St1); St2 := St1; WriteLn; WriteLn('The student record is : '); WriteStu(St2); end.