Presentation is loading. Please wait.

Presentation is loading. Please wait.

Code examples MakingCircles.java Circle.java Loopy.java

Similar presentations


Presentation on theme: "Code examples MakingCircles.java Circle.java Loopy.java"— Presentation transcript:

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.


Download ppt "Code examples MakingCircles.java Circle.java Loopy.java"

Similar presentations


Ads by Google