// Tyler Rigsby, CSE 142 // Prints different patterns using for loops // Note: I have included here the drawings, loop tables, and pseudocode // used in class to illustrate our progression. These should all be left // out of your personal code when you turn in. public class LoopPatterns { public static void main(String[] args) { sequence(); dotsNums(); } /* Mapping loop counter to number sequences 17 13 9 5 1 */ public static void sequence() { /* for (each of five numbers) { print number } */ for (int count = 1; count <= 5; count++) { System.out.print((21 - 4 * count) + " "); } System.out.println(); } /* Mapping complex patterns to loop counters ....1 ...2 ..3 .4 5 line dots -1 * line -1 * line + 5 1 4 -1 4 2 3 -2 3 3 2 -3 2 4 1 -4 1 5 0 -5 0 */ public static void dotsNums() { /* for (each of 5 lines) { print some dots (decreasing) print line number println } */ for (int line = 1; line <= 5; line++) { for (int dots = 1; dots <= (-1 * line) + 5; dots++) { System.out.print("."); } System.out.println(line); } } }