// Whitaker Brand // TA: Miya Natsuhara // CSE142 // Section AB // // This program prints out a Diamond shape that // can scale to become larger or smaller by changing // the class constant SIZE. // // Other side note, I chopped out most of the comments // so that you can see what a "finished" version should // look like. If you'd like a more annotated version, // take a look at Diamond3 public class Diamond4 { public static final int SIZE = 3; // try other values, like // 4, 8, 15, 16, 23, and 42! public static void main(String[] args) { upTriangle(); downTriangle(); } // prints out an upwards facing triangle public static void upTriangle() { for (int i = 1; i <= SIZE; i++) { for (int spaces = 1; spaces <= SIZE - i; spaces++) { System.out.print(" "); } System.out.print("/"); for (int periods = 1; periods <= 2 * i - 2; periods++) { System.out.print("."); } System.out.println("\\"); } } // prints a downwards-pointing triangle public static void downTriangle() { for (int i = 1; i <= SIZE; i++) { for (int spaces = 1; spaces <= i - 1; spaces++) { System.out.print(" "); } System.out.print("\\"); for (int periods = 1; periods <= 2 * SIZE - 2 * i; periods++) { System.out.print("."); } System.out.println("/"); } } }