Previous topic |
Next topic |
Ada Home Page |
Index
Multiple selections
Complex specifications may require a series of choices to be made between
- a series of related choices (multiple alternative if)
- nested independent choices (nested if)
Use a Multiple alternative if
- a series of related conditions
Statement form
statement_before
if test_1 then
statement(s)_1;
elsif test_2 then
statement(s)_2;
else
statement(s)_3;
end if;
statement_after
Statement semantics
Decision tables
A multiple alternative if may often be summarised by a decision
table listing the alternatives & when used
Balance after withdrawal | Action |
>=0 | Accept withdrawal |
>=-50 and < 0 | Overdraft |
<-50 | Refuse withdrawal |
An example program
shows the use of multiple alternative if statements to process a
withdrawal from a bank, according to the decision table above.
Previous topic |
Next topic |
Ada Home Page |
Index
c-lokan@adfa.oz.au / 13 Feb 96