Making Choices (Chap 3)
Expressions and Statements
Blocks
A block with a declaration
Boolean Expressions
Logical Operators
The if statement
Semicolons and the if statement
Example: Sort three numbers
Pseudocode
PPT Slide
The if-else statement
Finding the minimum
A block in an if-else statement
Common Programming Error
Nested if-else statements
if-else-if-else-if-else...
The dangling else problem
The while statement
A simple loop
Average - pseudocode - no while
Average - pseudocode - using while
General form of a while loop
Average.java
The for statement
Switch
A Final Example
Email: charlie@cs.ucsc.edu
Home Page: http://www.cse.ucsc.edu/~charlie