// This program produces as output an ASCII art representation of a diamond. public class Diamond1 { public static void main(String[] args) { drawLine(); drawDiamond(); drawLine(); } // outputs a solid line public static void drawLine() { for (int i = 1; i <= 21; 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 <= 4; row++) { System.out.print("|"); for (int spaces = 1; spaces <= 12 - 3 * row; spaces++) { System.out.print(" "); } for (int stars = 1; stars <= 6 * row - 5; stars++) { System.out.print("*"); } for (int spaces = 1; spaces <= 12 - 3 * row; spaces++) { System.out.print(" "); } System.out.println("|"); } } // outputs the bottom half of the diamond public static void drawBottom() { for (int row = 4; row >= 1; row--) { System.out.print("|"); for (int spaces = 1; spaces <= 12 - 3 * row; spaces++) { System.out.print(" "); } for (int stars = 1; stars <= 6 * row - 5; stars++) { System.out.print("*"); } for (int spaces = 1; spaces <= 12 - 3 * row; spaces++) { System.out.print(" "); } System.out.println("|"); } } }