Chapter 6 - Iteration. In this chapter we will: discuss the use of repetition (iteration) in programming algorithms; describe the Java while, for, and do-while statements; demonstrate the use of loop invariants to verify the correctness of loops; show the use of loops in data entry and computer animation.
Chapter Iteration Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N Kamin, D Mickunas, E Reingold Chapter Preview In this chapter we will: • discuss the use of repetition (iteration) in programming algorithms • describe the Java while, for, and do-while statements • demonstrate the use of loop invariants to verify the correctness of loops • show the use of loops in data entry and computer animation while Loop • Repeated executes body of the loop which can be a single or compound statement • A while loop will execute as long as its condition is true • An infinite loop will occur if the condition never becomes false • Example: count = 1; while (count