Download presentation
Presentation is loading. Please wait.
Published byTorfinn Jenssen Modified over 5 years ago
1
Code examples MakingCircles.java Circle.java Loopy.java
Loops Code examples MakingCircles.java Circle.java Loopy.java
2
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
3
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?
4
The while loop Flowchart
statement(s) true boolean expression? false Another name is precondition loop – You evaluate the condition before executing the body.
5
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.
6
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.