Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project2;
- {$APPTYPE CONSOLE}
- uses
- System.SysUtils;
- const
- ErrorMessage = 'Error! Enter name (nonempty string, starts with uppercase letter)';
- var
- IsInvalid, HasAllLetters : Boolean;
- Alphabet : set of 'A'..'z';
- Name : String;
- i : Integer;
- begin
- Alphabet := ['A'..'z'];
- IsInvalid := True;
- Writeln('This program can recognize and greet one of 5 friends');
- while IsInvalid do
- try
- HasAllLetters := True;
- Writeln('Enter your shortened name');
- Readln(Name);
- if Name <> '' then
- begin
- for i := 1 to Length(Name) do
- if not (Name[i] in Alphabet) then
- HasAllLetters := False;
- if HasAllLetters then
- IsInvalid := False
- else
- Writeln(ErrorMessage)
- end
- else
- Writeln(ErrorMessage);
- except
- Writeln(ErrorMessage);
- end;
- if Name = 'Lynn' then
- Writeln('Hello Carolyn!')
- else
- if Name = 'Mike' then
- Writeln('Hello Michael!')
- else
- if Name = 'Bob' then
- Writeln('Hello Robert!')
- else
- if Name = 'Liz' then
- Writeln('Hello Elizabeth!')
- else
- if Name = 'Peg' then
- Writeln('Hello Margareth!')
- else
- Writeln('I DON''T KNOW YOU!');
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement