Previous topic | Next topic | Ada Home Page | Index

Multiple selections

Complex specifications may require a series of choices to be made between Use a Multiple alternative if

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 withdrawalAction
>=0Accept withdrawal
>=-50 and < 0Overdraft
<-50Refuse 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