7.7 Summary


7.7 Summary

The selection design structure, also known as alternation, is very useful to construct algorithms for simple problems. The two statements in pseudocode explained are the if and case statements. The first one is applied when there are two possible paths in the algorithm, depending on how the condition evaluates. The case statement is applied when the value of a variable is tested, and there are multiple possible values; one path is used for every value selected.

The condition in the if statement consists of a Boolean expression, which evaluates to a truth-value (true or false). It is constructed with relational operators between two data items. Conditions that are more complex are formed from simple ones using logical operators.

The KJP language (as other programming languages) includes equivalent statements for the selection structures.




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net