Chapter 7: Selection


7.1 Introduction

The previous chapter presented the techniques and notations used for describing algorithms. Four design structures are used for the detailed description of algorithms. These are sequence, selection, repetition, and input/output. This chapter explains the selection design structure in algorithms and its application to simple problem solutions. Two statements are discussed, the if and the case statements.

These statements include conditions, which are Boolean expressions that evaluate to a truth-value (true or false). Simple conditions are formed with relational operators for comparing two data items. Compound conditions are formed by joining two or more simple conditions with the logical operators.

Two examples are discussed: the solution of a quadratic equation and the solution to a modified version of the salary problem (introduced in the previous chapter).




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