Objectives

Students will be able to:

  • understand that a block of code often needs to run more than once.
  • understand that a loop can be designed to run a block of code more than once.
  • understand that looping is known as iterating ie repeating
  • understand that a loop can be controlled by a variable
  • understand pseudocode for a count-controlled loop
  • understand a basic syntax of a for loop in Java.

Introduction to Iteration

count-controlled loops

Minimum Value Tracker

Enter up to 10 numbers less than 1000. If the minimum changes, it will be displayed.

 

minValue: 1000

Observations

  1. Before the tracker is used, a high value has been assigned to a variable, minValue
  2. A loop allows the user to repeat the same action 10 times - enter a value from the keyboard
  3. In the loop, if the user's number is less than the minimum value, it becomes the minumum value!

Task

Start a new project in your IDE - MinimumTracker

Paste the into your Main.java file

Open the worksheet below and let's explore iteration in Java!

Tags

integratedsyntax development environment machine code translate type errorcompile