Making Choices (Chap 3)

12/18/01


Click here to start


Table of Contents

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

PPT Slide

PPT Slide

The if-else statement

Finding the minimum

A block in an if-else statement

Common Programming Error

Common Programming Error

Nested if-else statements

Nested if-else statements

Common Programming Error

if-else-if-else-if-else...

if-else-if-else-if-else...

if-else-if-else-if-else...

The dangling else problem

The dangling else problem

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

PPT Slide

PPT Slide

Common Programming Error

The for statement

PPT Slide

PPT Slide

PPT Slide

Switch

PPT Slide

PPT Slide

PPT Slide

A Final Example

PPT Slide

PPT Slide

PPT Slide

PPT Slide

PPT Slide

PPT Slide

PPT Slide

Author: charlie

Email: charlie@cs.ucsc.edu

Home Page: http://www.cse.ucsc.edu/~charlie