/* Loops1.java CIS 111 Sept. 24, 2007 David G. Klick Demonstrates some simple repetition/loops (counter controlled) */ public class Loops1 extends CIS111App { public static void main(String[] args) { int i; // this is called a post-test loop because the test // is at the end of the loop print("\nA do loop: "); i = 1; do { print(i + " "); i = i + 1; } while (i <= 10); // this is called a pre-test loop because the test // is at the beginning of the loop print("\nA while loop: "); i = 1; while (i <= 10) { print(i + " "); i = i + 1; } // the for loop is also a pre-test loop print("\nA for loop: "); for (i=1; i<=10; i++) { print(i + " "); } } }