program phone;
{This program determines where in Mongolia you are calling when you
enter in an area code and the first three digits of the phone number.}
{It is a good example of how to use if, then, else statements which
are nestled inside of other if, then else statements.}
{Please note : formating is very important and you will be marked on it!}
uses
WinCRT;
var
AreaCode, FirstThree:Integer;
begin
Write ('Please enter the area code of where you are calling : ');
Readln (AreaCode);
Write ('Please enter the first three digits of the phone # : ');
Readln (FirstThree);
if (AreaCode>=200) and (AreaCode<500) {a number between 200 and 499}
then
begin
if (FirstThree>=500) and (FirstThree<900) {first three is a number between 500 and 899}
then
begin
Writeln ('You are calling E. Mongolia.');
Writeln ('The area code there is ', AreaCode);
end
else {if first three is any other number besides 500 - 899}
begin
Writeln ('You are calling W. Mongolia.');
Writeln ('The area code there is ', AreaCode);
end;
end
else
if(FirstThree < 800) or (FirstThree >= 900)
then
begin
writeln ('You are calling N. Mongolia');
writeln ('The area code there is ', AreaCode);
end
else
begin
writeln ('You are calling S. Mongolia');
writeln ('The area code there is ', AreaCode);
end;
end.
{Make sure that you can trace this program and understand it, you will need
to know how to do this to write your posneg.pas, posneg0.pas and telegram.pas
programs! Good luck. I will be back next week if you require extra help.}