Dear Sir,

This is the 3rd part of the question, I want to find and list the finalists.

Cheers,

First you have to create a 1,new file then 2,add member then 3,open and read then 4, you can change the phone number then 5, you can find only 3 finalists(sorry exchange the number in the code)and last 6 exit from the main program.... :)
This program is written in Turbo Pascal 7.0 by me.
Sorry for the missing comments :'(
Good day. :D

Program Solution01;

Uses Crt;

Type
   TString = String[30];

   TRecord = Record
               FirstName  :TString;
               LastName   :TString;
               PhoneNumber:LongInt;
            End;


Const TheFile = 'C:\Record.dat';


Var User_Choice,Rnd:Integer;
    Bag:Set Of Byte;
    All:Array[0..99]Of TRecord; {max 100 member}
    A:Array[1..10]Of TRecord;
    F:File Of TRecord;
    i,aindex,bindex,cindex,counter,FS,CF:Byte;


Procedure MainMenu;Forward;

Procedure Terminate; {6. option}
Begin
   WriteLn;
   Write('Press enter to quit.');
   ReadLn;
   ReadLn;
   Halt;
End;

Procedure CreateNew;{1. option}
Begin
   ClrScr;
   Assign(F,TheFile);
   Rewrite(F);
   Close(F);
   WriteLn('The file is empty.');
   WriteLn('File created: ',TheFile);
   WriteLn('Now you can add members to this file.');
   Write('Press enter to continue.');
   ReadLn;
   MainMenu;
End;

Procedure AddNewMember; {2. option}
Begin
   Assign(F,TheFile);
   ClrScr;
   WriteLn;
   WriteLn('How many guy do you want to add,max 10 members?');
   Write('Your Choice is: ');
   ReadLn(FS);
   For i:=1 to Fs Do Begin
      WriteLn('---');
      Write(i,'. First Name: ');
      ReadLn(A[i].FirstName);
      Write('   Last Name: ');
      ReadLn(A[i].LastName);
      Write('   Phone: ');
      ReadLn(A[i].PhoneNumber);
      If (i=FS) Then WriteLn('---');
   End;
   WriteLn;
   Reset(F);
   FileMode:=2;
   Seek(F,FileSize(F));
   For i:=1 to FS Do Write(F,A[i]);
   Close(F);
   Write('Writting is success.Press enter to continue.');
   ReadLn;
   MainMenu;
End;

Procedure OpenAndRead;{3. option}
Begin
   ClrScr;
   Assign(F,TheFile);
   Reset(F);
   aindex:=0;
   While (EoF(F)=False)Do Begin
      Read(F,All[aindex]);
      WriteLn('-',aindex,'-');
      WriteLn('First Name: ',All[aindex].FirstName);
      WriteLn('Last Name: ', All[aindex].LastName);
      WriteLn('Phone: ',All[aindex].PhoneNumber);
      Inc(aindex);
   End;
   WriteLn;
   Write('Press enter to Main menu.');
   ReadLn;
   MainMenu;
End;

Procedure ChangePhone; {4. option}
Begin
  ClrScr;
  Write('Please give me the member''s number: ');
  ReadLn(CF);
  Assign(F,TheFile);
  Reset(F);
  bindex:=0;
  While (EoF(F)=False) Do Begin
     Read(F,All[bindex]);
     If (EoF(F)=True) Then Break;
     Inc(bindex,1);
  End;
  If (CF>bindex) Then Begin
     Write('Too big number entered.Can''t change.');
     ReadLn;
     MainMenu;
  End;
  WriteLn(CF,'. First Name: ',All[CF].FirstName);
  WriteLn('Last Name: ',All[CF].LastName);
  WriteLn('Last entered phone number: ',All[CF].PhoneNumber);
  Write('The new phone number: ');
  ReadLn(All[CF].PhoneNumber);
  Seek(F,CF);
  Write(F,All[CF]);
  Close(F);
  Write('Press enter to continue.');
  ReadLn;
  MainMenu;
End;

Procedure FindThree;{5. option}
Begin
   ClrScr;
   Assign(F,TheFile);
   Reset(F);
   cindex:=0;
   While (EoF(F)=False) Do Begin
     Read(F,All[cindex]);
     If(EoF(F)=True)Then Break;
     Inc(cindex);
   End;
   If (cindex<=3) Then Begin
     Write('The members are too few.');
     ReadLn;
     MainMenu;
   End;
   Randomize;
   Bag:=[];{empty}
   For i:=1 To 3 Do Begin
     Rnd:=Random(cindex);
     If (Rnd In Bag) Then i:=i-1
     Else Begin
        Bag:=Bag+[Rnd];
        WriteLn(i,'. First Name: ',All[Rnd].FirstName);
        WriteLn('Last Name: ',All[Rnd].LastName);
        WriteLn('Phone: ',All[Rnd].PhoneNumber);
     End;
   End;
   Close(F);
   ReadLn;
   MainMenu;
End;


Procedure MainMenu;{0. option}
Begin
   ClrScr;
   WriteLn;
   WriteLn('Select one number between 0 and 6.');
   WriteLn;
   WriteLn('    0.Refresh.');
   WriteLn;
   WriteLn('    1.Create a new file.');
   WriteLn;
   WriteLn('    2.Add new member.');
   WriteLn;
   WriteLn('    3.Open and read an existing file.');
   WriteLn;
   WriteLn('    4.Change phone number for one person.');
   WriteLn;
   WriteLn('    5.Find the 3 finalist.');
   WriteLn;
   WriteLn('    6.Exit.');
   WriteLn;
   Write('Your Choice is : ');
   {$I-}
   ReadLn(User_Choice);
   {$I+}
   If IoResult<>0 Then Terminate;
   Case (User_Choice) Of
      0:MainMenu;
      1:CreateNew;
      2:AddNewMember;
      3:OpenAndRead;
      4:ChangePhone;
      5:FindThree;
      6:Terminate;
   End;

End;


Begin {main}

   MainMenu;

End.{end of main}
{
-=Created By FlamingClaw=-
-=2009.04.28=-
}
This question has already been answered. Start a new discussion instead.