Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 5: Program Logic and Indefinite Loops

Download Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 5: Program Logic and Indefinite Loops

Post on 16-Dec-2015

215 views

Category:

Documents

3 download

Embed Size (px)

TRANSCRIPT

<ul><li> Slide 1 </li> <li> Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 5: Program Logic and Indefinite Loops </li> <li> Slide 2 </li> <li> Copyright 2006 by Pearson Education 2 Objectives While Loop Instead of Counting Loop Use a Random # Generator object Variation - the do/while loop </li> <li> Slide 3 </li> <li> Copyright 2006 by Pearson Education 3 Definite loops - FOR definite loop: One that executes a known number of times. The for loops we have seen so far are definite loops. We often use language like, "Repeat these statements N times." "For each of these 10 things,...." Examples: Print "hello" 10 times. Find all the prime numbers up to an integer n. Print each odd number between 5 and 127. </li> <li> Slide 4 </li> <li> Copyright 2006 by Pearson Education Flowchart of For Loop Chapter 5 Slide 4 intCount </li></ul>