Chapter 6 Selection Statements


Click here to start

Table of contents

Chapter 6 Objectives

The if Statement

Syntax for the if Statement

Control Flow

Relational Operators

Compound Statements

Style Guide

The if-then Statement

Control Flow of if-then

Boolean Expressions and Variables

Short-Circuit Evaluation

Operator Precedence Rules

The Nested-if Statement

Control Flow of Nested-if Statement

Writing a Proper if Control

if – else if Control

Matching else

ListBox

ListBox – Add Items

ListBox – Items in colorList

ListBox Methods

ListBox – Processing the User Selection

The switch Statement

Syntax for the switch Statement

switch With No break Statements

switch With break Statements

switch With the default Block

Sample Program: Drawing Shapes

DrawShape – Design

DrawShape – Object Diagram

Loan Calculator – Development Steps

Author: Robert Rittenhouse

E-mail: rob@cs1.mcm.edu

Homepage: http://cs1.mcm.edu/~rob/