_
> ____
> program telephone;
> uses crt;
> {
> Name :
> Date : 6/12/01
> File : Telephone 2002
> }
> type
> phonebook = array [1..20, 1..20] of longint;
> var
> phone : phonebook;
> count : integer;
> choice : char;
> coin : longint;
> money : longint;
> calllength : longint;
> time : longint;
> number : longint;
> exitprog : string;
> i : integer;
> mins : integer;
> secs : integer;
> procedure welcombe;
> begin
> clrscr;
> gotoXY(35,6);
> writeln('WELCOME');
> gotoXY(35,7);
> writeln('=======');
> gotoXY(32,12);
> writeln('TELEPHONE 2002');
> gotoXY(23,20);
> write('Programmer : David Cox - 12345678');
> gotoXY(28,23);
> write('HIT "RETURN" TO CONTINUE');
> readln;
> end;
> procedure menu;
> begin
> repeat
> clrscr;
> gotoXY(35,6);
> writeln('SERVICE RATES');
> gotoXY(20,12);
> writeln('A : Local call (1p for 30 secs)');
> gotoXY(20,13);
> writeln('B : Short Distance (1p for 20 secs)');
> gotoXY(20,14);
> writeln('C : Lond Distance call (1p for 10 secs)');
> gotoXY(10,20);
> write('Please make your choice form the list : ');
> readln(choice);
> choice := upcase(choice);
> case choice of
> 'A' : calllength := 30;
> 'B' : calllength := 20;
> 'C' : calllength := 10;
> end;
> until (choice='A') or (choice='B') or (choice='C');
> end;
> procedure entermoney;
> begin
> money := 0;
> repeat
> clrscr;
> gotoXY(5,20);
> writeln('Total amount entered : ',money);
> gotoXY(35,6);
> writeln('GIVE ME MONEY');
> gotoXY(12,10);
> writeln('Please enter one coin at a time, followed by
> "ENTER"');
> gotoXY(25,11);
> writeln('When finished enter a 0 (zero)');
> gotoXY(32,13);
> write('Coin entered : ');
> readln(coin);
> if (coin<>5) and (coin<>10) and (coin<>20) and (coin<>50)
> and (coin<>100) and (coin<>0) then
> begin
> clrscr;
> gotoXY(10,10);
> writeln(' COIN REJECTED. 5,10,20,50,100 coins
> only please');
> readln;
> gotoXY(10,10);
> writeln('
> ');
> end
> else
> begin
> money := money + coin;
> gotoXY(5,20);
> writeln('Total amount entered : ',money);
> end;
> until (coin = 0);
> clrscr;
> gotoXY(35,4);
> writeln('SERVICE RATES');
> gotoXY(20,10);
> writeln('A : Local call (1p for 30 secs)');
> gotoXY(20,11);
> writeln('B : Short Distance (1p for 20 secs)');
> gotoXY(20,12);
> writeln('C : Lond Distance call (1p for 10 secs)');
> gotoXY(10,18);
> write('You have chosen service rate : ',choice);
> time := money * calllength;
> mins := (money * calllength) div 60;
> secs := (money * calllength) mod 60;
> gotoXY(10,19);
> write('Your have a total time of : ',mins,' minutes ',secs,'
> seconds');
> readln;
> end;
> procedure dial;
> begin
> clrscr;
> gotoXY(10,10);
> write('Please enter the number to be dialed (no spaces) : ');
> readln(number);
> phone[count,1] := number;
> phone[count,2] := time;
> clrscr;
> gotoXY(25,8);
> writeln(number);
> gotoXY(20,12);
> writeln('Dialing..............');
> gotoXY(20,14);
> write('Connected..');
> readln;
> end;
> procedure final;
> begin
> clrscr;
> gotoXY(12,5);
> write('Phone number dialed Time Purchased');
> gotoXY(12,6);
> write('=================== ==============');
> writeln;
> for i := 1 to count do
> begin
> gotoXY(10,(i+7));
> writeln(i,' ',phone[i,1]);
> gotoXY(45,(i+7));
> write(phone[i,2]);
> end;
> readln;
> end;
> procedure sort;
> var
> n,index : integer;
> sorted : boolean;
> procedure SWAP (var Val1, Val2:integer);
> var
> temp : integer;
> begin
> temp := Val1;
> Val1 := Val2;
> Val2 := temp;
> end;
> begin n:=count;
> repeat
> sorted := true;
> n := n-1;
> for index := 1 to n do
> begin
> if phone[index,2] < phone[index+1,2] then
> begin
> sorted := false;
> SWAP(phone[index,2], phone[index+1,2]);
> end;
> end;
> until sorted;
> clrscr;
> gotoXY(12,5);
> write('Phone number dialed Time Purchased');
> gotoXY(12,6);
> write('=================== ==============');
> writeln;
> for i := 1 to count do
> begin
> gotoXY(10,(i+7));
> writeln(i,' ',phone[i,1]);
> gotoXY(45,(i+7));
> write(phone[i,2]);
> end;
> readln;
> end;
> begin {}
> count :=1;
> repeat
> welcombe;
> menu; {call menu procedure}
> entermoney; {call money entry procedure}
> dial;
> gotoXY(26,20);
> write('Anthor number Y / N : ');
> readln(exitprog);
> exitprog := upcase(exitprog);
> if (exitprog = 'Y') then
> begin
> count := count+1
> end;
> until (exitprog = 'N');
> final;
> sort;
> end.
> --
> ===============================
> Live Long & Prosper :-)
> ===============================