Download presentation
Presentation is loading. Please wait.
Published byἸεζάβελ Αλιβιζάτος Modified over 6 years ago
1
2-1 Making Decisions Sample assignment statements
PayAmount = Hours * Rate PayAmount = 40*Rate + (Hours – 40)*Rate*1.5
2
2-2 The IF Statement The most common decision structure is the IF statement. A condition is a boolean expression that evaluates to either true or false. Conditions typically involve one of the six relational operators.
3
2-2 The IF Statement (cont.)
4
Simple IF Statements
5
Solving the Overtime Problem
6
2-3 Nested IF Statements The term nested IF refers to an IF statement contained within the true or false branch of another IF statement.
7
2-3 Nested IF Statements (cont.)
8
Long Distance Billing Problem
9
2-4 Compound Conditions A compound condition consists of two conditions within parentheses joined by a logical operator. The four most common logical operators are NOT, AND, OR, and XOR.
10
2-4 Compound Conditions (cont.)
11
2-4 Compound Conditions (cont.)
12
Chapter Summary A condition is an expression that evaluates to either true or false. IF statements use conditions to choose between actions. The true and false branches of an IF statement may contain any valid statement, including other IF statements. A compound condition is two or more conditions joined by a logical operator.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.