CS 101 - 9/13/2011 When drawing a sqaure, we repeat the same steps 4 times. Looping statements - allows some number of operations to be repeated some number of times. while statement general form: while ( ) { } the will continue to be executed while the exvaluated to TRUE Often we need to use the relational operator in our == equality != inequality (not equal) > greater than >= greater than or equal < less than <= less than or equal Example of a while loop int count; count = 1; while ( count <= 4 ) { System.out.println ("Count: " + count); count = count + 1; } When writing a loop, a common error is not having the ever become FALSE. This is called an Infinite Loop When drawing a regular shape of X sides, each angle should be of 360/X degrees. Triangle (3 sides) 360/3 = 120 Square (4 sides) 360/4 = 90 Pentagon (5 sides) 360/5 = 72 Hexagon (6 sides) 360/6 = 60 Computer Scientists count Strange!!!! They start counting from zero instead of one. So a loop that runs tens times normally appears as follows: count = 0; while ( count < 10 ) { System.out.println ("Count: " + count); count = count + 1; } System.out.println ("Count after loop: " + count); For the first project, we will be drawing on a picture. When we create the turtle, we give the constructor a picture instead of a world. So the next question is: How do we create a Picture. When creating a picture we can create a blank (all white) picture of whatever size we want with the Picture contructor Picture (int width, int height); Or open an existing Picture, with the constructor: Picture (String filename);