In class practice   Conditional Statement

July 02, 2007

1. Compare and run the code simpleLoop.java, simpleForLoop.java, and simpleDoLoop.java. Add break and continue to see what happens.

2. Run the code ForExamples.java, AsteriskPattern.java and NumberPattern.java.

3. Write a program to ask a user to input a positive integer N. Then the program compute the sum the first N positive integers: sum = 1+2+3+...+(N-1)+N.

    (a) use while() {   } structure.

    (b) use for structure

    (c) use  do while sturcuture.

 4. Write a program to ask a user to input a positive integer N. The program output the pattern with N rows.