Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project2;
- {$APPTYPE CONSOLE}
- uses
- System.SysUtils;
- var
- IsInvalid: Boolean;
- Name: Char;
- Alphabet : Set of 'A'..'z';
- begin
- Alphabet := ['A'..'Z'];
- IsInvalid := True;
- Writeln('This program can recognize and greet one of 5 friends');
- while IsInvalid do
- try
- Writeln('Enter your shortened name');
- Readln(Name);
- if Name in Alphabet then
- IsInvalid := False
- else
- Writeln('Error! Enter name (nonempty string, starts with uppercase letter)')
- except
- Writeln('Error! Enter name (nonempty string, starts with uppercase letter)');
- end;
- case ord(Name) of
- 68 : writeln('Hello Danny!');
- 77 : writeln('Hello Mike!');
- 74 : writeln('Hello John!');
- 82 : writeln('Hello Robert!');
- 87 : writeln('Hello William!');
- else writeln('I DON''T KNOW YOU!');
- end;
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement