Previous topic |
Ada Home Page |
Index
Selection with multiple If
-- Fintan Culwin Sept '88 v1.0
-- program to illustrate multiple if selection
-- see text p122-123
with TEXT_IO;
use TEXT_IO;
procedure demo_multif is
ch : CHARACTER; -- char to classify
begin -- of demo_multif
-- get char from user
PUT ( "Enter character> ");
GET ( ch ); SKIP_LINE;
-- use multiple if to classify a single character
if (ch = '?' ) then
PUT_LINE("is a question mark");
elsif (ch = '!') then
PUT_LINE("is an exclamation mark");
elsif ((ch >= 'A') and (ch <='Z')) then
PUT_LINE("is upper case");
elsif ((ch >= 'a') and (ch <='z')) then
PUT_LINE("is lower case");
elsif ((ch >= '0') and (ch <='9')) then
PUT_LINE("is a digit");
elsif ((ch = '.') or (ch = ',') or (ch = ';')
or (ch = ':')) then
PUT_LINE("is punctuation");
end if;
end demo_multif;
Previous topic |
Ada Home Page |
Index
c-lokan@adfa.oz.au / 13 Feb 96