Unit 06 · lesson

Checkpoint 2: Control Flow and Method Design

Build a small Java program that makes at least one decision, iterates over or toward a bounded state, and decomposes the work into meaningful methods.

Requirement

Choose a problem with a measurable rule: score analysis, sensor samples, match statistics, inventory counts, study-session records, or another school-appropriate dataset.

Your program must include:

  • at least one validated input/state rule;
  • at least one conditional decision;
  • one loop with an explainable termination condition;
  • at least three methods with distinct responsibilities;
  • one numeric or text result that can be verified independently.

Evidence

Algorithm before code

Write the decision and iteration logic in structured plain language or pseudocode before presenting Java.

Control-flow choice

Name one alternative control structure that could have been used and explain why your chosen structure better exposes this requirement.

Termination argument

For the loop, identify:

  • initial state;
  • continuation condition;
  • state change;
  • terminal state;
  • one invariant or count that should remain true.

Method contracts

For each major method state its inputs, output/effect, valid domain, and responsibility.

Boundary cases

Include cases at or immediately around at least three boundaries. Examples: zero count, exactly passing, one below passing, first element, last element, empty text.

Integration fault

Preserve one Version 1 defect caused by the relationship between components, such as reversed arguments, wrong branch priority, or a loop boundary that causes the wrong number of values to reach a method.

Identify the responsible boundary and make a controlled correction.

Regression evidence

After the fix, rerun the original passing cases plus the case that exposed the defect.

Mastery standard

The submission must show more than working syntax. Another programmer should be able to reconstruct why the control flow terminates, why the methods are separated, and why the tests distinguish correct from almost-correct behavior.