Skip to main content
Logo image

Java, Java, Java: Object-Oriented Problem Solving, 2022E

Section 6.13 Chapter Summary

Subsection 6.13.1 Technical Term

conditional loop loop bound sentinel bound
counting loop loop entry condition unit indexing
do-while statement nested loop updater
infinite loop postcondition while statement
initializer precondition zero indexing
limit bound priming read
loop body repetition structure

Subsection 6.13.2 Summary of Important Points

  • A repetition structure is a control structure that allows a statement or sequence of statements to be repeated.
  • All loop structures involve three elements—an initializer, a loop entry condition or a loop boundary condition, and an updater.
  • When designing a loop, it is important to analyze the loop structure to make sure that the loop bound will eventually be satisfied.
  • The for statement has the following syntax:
    for (  initializer ;  loop entry condition ; updater )
        for loop body 
    A summary of various loop bounds:
    Bound Example
    Counting k \(\lt\) \(100\)
    Sentinel input != 9999
    Flag done != true
    Limit amount \(\lt\) \(0.5\)
  • The while statement takes the following form:
    while ( loop entry condition )
        loop body
  • The do-while statement has the following general form:
        loop body 
    } while ( loop condition );
  • When designing a loop, it is important to analyze the loop structure to make sure that the loop bound will eventually be satisified. The table below summarizes the types of loop bounds that we have identified.
  • Structured programming is the practice of writing programs that are built up from a small set of predefined control structures—the sequence, selection, repetition, and method-call structures. An important feature of these structures is that each has a single entry and exit.
  • A precondition is a condition that must be true before a certain code segment executes. A postcondition is a condition that must be true when a certain code segment is finished. Preconditions and postconditions should be used in the design, coding, documentation, and debugging of algorithms and methods.

Solutions 6.13.3 Solutions to Self-Study Exercises

6.3 Counting Loops
6.3.7 Self-Study Exercises

6.3.8 Nested Loops

Self-Study Exercise

6.6 Conditional Loops
6.6.1 The While Structure, Revisited

Self-Study Exercises

6.6.2 The Do-While Structure

Self-Study Exercises

6.9 Principles of Loop Design
6.9.1 Loop Summary

Self-Study Exercise

6.10 The switch Multiway Selection Structure
6.10.1 Switch

Self-Study Exercises

6.11 OBJECT-ORIENTED DESIGN: Structured Programming
6.11.4 Effective Program Design

Self-Study Exercises
You have attempted of activities on this page.