// This program produces as output an ASCII art representation of a diamond. // This version includes a class constant for drawing mirrors of different // sizes. public class Diamond2 { public static final int SIZE = 8; // change this to scale the diamond public static void main(String[] args) { drawLine(); drawDiamond(); drawLine(); } // outputs a solid line public static void drawLine() { for (int i = 1; i <= 6 * SIZE - 3; i++) { System.out.print("="); } System.out.println(); } // outputs the diamond public static void drawDiamond() { drawTop(); drawBottom(); } // outputs the top half of the diamond public static void drawTop() { for (int row = 1; row <= SIZE; row++) { System.out.print("|"); for (int spaces = 1; spaces <= 3 * SIZE - 3 * row; spaces++) { System.out.print(" "); } for (int stars = 1; stars <= 6 * row - 5; stars++) { System.out.print("*"); } for (int spaces = 1; spaces <= 3 * SIZE - 3 * row; spaces++) { System.out.print(" "); } System.out.println("|"); } } // outputs the bottom half of the diamond public static void drawBottom() { for (int row = SIZE; row >= 1; row--) { System.out.print("|"); for (int spaces = 1; spaces <= 3 * SIZE - 3 * row; spaces++) { System.out.print(" "); } for (int stars = 1; stars <= 6 * row - 5; stars++) { System.out.print("*"); } for (int spaces = 1; spaces <= 3 * SIZE - 3 * row; spaces++) { System.out.print(" "); } System.out.println("|"); } } }