Program Logic

Learning Unit 7

Repetition Structures

Repetition Structures

Learning Objectives

In addition to all previous competencies, upon completion of this unit, you should be able to:

Unit Learning Activities

In this unit you will learn the basics of repetition structures. After all, computers are very good at repeating a sequence of commands over and over without tiring. Repetition structures should be firmly implanted into your bag of tricks. Please note, this unit includes a detailed example which I highly recommend you type into a NetBeans project, make sure it works, and step through the code.

Each link below takes you to a specific chapter within this unit. Please take the time to review all the chapters and when available, complete the interactive activities.

"Success is the sum of small efforts - repeated day in and day out." - Robert Collier
  1. Repetition Structures Overview
    • Pre-test Loops
    • Post-test Loops
    • Counter-Controlled Loops
    • Condition-Controlled Loops
    • Infinite Loops
    • What You Learned
  2. Counter-Controlled Loops
    • Counter-Controlled while Loop
    • Counter-Controlled for Loop
    • What You Learned
  3. Condition-Controlled Loops
    • Stop on a Sentinel
    • Using Two Sentinels
    • Things to Remember
  4. Combining Repetition Structures and Decision Structures
    • Testing for true
    • Code Example
    • Repetition Structure with Nested Decision
    • Things to Remember
    • Input Validation
    • Detailed Example
  5. Nested Loops
    • Code Example
    • The Concept
    • Interactive Live Demo
  6. This unit includes the following detailed example