// CSE 142 // Homework X // Marty Stepp // // This program draws a figure using nested loops. // Second version that uses a class constant to control // the figure size. // public class ComplexFigure2 { public static final int SIZE = 6; public static void main(String[] args) { drawArea1(); drawArea2(); drawArea3(); drawArea1(); } // prints top/bottom line of # and = marks public static void drawArea1() { System.out.print("#"); for (int equal = 1; equal <= 4 * SIZE; equal++) { System.out.print("="); } System.out.println("#"); } // prints expanding pattern of <> for top half of figure public static void drawArea2() { for (int line = 1; line <= SIZE; line++) { // | System.out.print("|"); // spaces for (int space = 1; space <= (line * -2 + (2 * SIZE)); space++) { System.out.print(" "); } // <> System.out.print("<>"); // . for (int dot = 1; dot <= (line * 4 - 4); dot++) { System.out.print("."); } // <> System.out.print("<>"); // spaces for (int space = 1; space <= (line * -2 + (2 * SIZE)); space++) { System.out.print(" "); } // | System.out.println("|"); } } // prints contracting pattern of <> for bottom half of figure public static void drawArea3() { for (int line = SIZE; line >= 1; line--) { System.out.print("|"); for (int space = 1; space <= (line * -2 + (2 * SIZE)); space++) { System.out.print(" "); } System.out.print("<>"); for (int dot = 1; dot <= (line * 4 - 4); dot++) { System.out.print("."); } System.out.print("<>"); for (int space = 1; space <= (line * -2 + (2 * SIZE)); space++) { System.out.print(" "); } System.out.println("|"); } } }