Code examples MakingCircles.java Circle.java Loopy.java Loops Code examples MakingCircles.java Circle.java Loopy.java
UML Diagram bigSpot littleSpot radius: 6 radius: 2 Circle Name of class Data (attributes) Methods of the class radius: double Circle(double radius) getRadius(): double getArea(): double getCircumference(): double bigSpot littleSpot radius: 6 radius: 2 Circle(double radius) getRadius(): double getArea(): double getCircumference(): double Circle(double radius) getRadius(): double getArea(): double getCircumference(): double
Why loops? Where have we wanted to use a loop? What kinds of problems lend themselves to iteration? What do Java loop structures look like?
The while loop Flowchart statement(s) true boolean expression? false Another name is precondition loop – You evaluate the condition before executing the body.
The do-while Loop Flowchart statement(s) true boolean expression? false Another name is post condition loop – You evaluate the condition after executing the body.
The for Loop Flowchart statement(s) true boolean expression? false update Another name is counted loop – You typically will execute a for loop based on some counter.