Chapter 7


Click here to start

Table of contents

Chapter 7

Chapter 7 Objectives

Planning Loops

Common Errors

The while Statement

Syntax for the while Statement

Control Flow of while

More Examples

Example: Testing Input Data

while Loop Pitfall - 1

while Loop Pitfall - 2

while Loop Pitfall - 3

Checklist for Repetition Control

Useful Shorthand Operators

The do-while Statement

Syntax for the do-while Statement

Control Flow of do-while

Loop Control without Boolean Variable

Loop Control with Boolean Variable

ResponseBox

ResponseBox – Processing the Selection

ResponseBox – Sample Usage

ResponseBox – Other Usage

ResponseBox Methods

The for Statement

Syntax for the for Statement

Control Flow of for

Slide 28

The Nested-for Statement

Generating the Table

Formatting Integers

Formatting Real Numbers

Formatting Strings

Methods in The Format Class

Sample Program: Hi-Lo Game

HiLo – Design

HiLo – Object Diagram

HiLo Game – Development Steps

Author: Robert Rittenhouse

E-mail: rob@cs1.mcm.edu

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