// Variation of the Diamond1 program that uses a constant to allow for resizing // the diamond output and that introduces methods to capture structure. public class Diamond2 { public static final int SIZE = 8; public static void main(String[] args) { upTriangle(); downTriangle(); } public static void upTriangle() { for (int line = 0; line < SIZE; line++) { for (int i = 0; i < SIZE - 1 - line; i++) { System.out.print(" "); } System.out.print("/"); for (int i = 0; i < 2 * line; i++) { System.out.print("."); } System.out.println("\\"); } } public static void downTriangle() { for (int line = SIZE - 1; line >= 0; line--) { for (int i = 0; i < SIZE - 1 - line; i++) { System.out.print(" "); } System.out.print("\\"); for (int i = 0; i < 2 * line; i++) { System.out.print("."); } System.out.println("/"); } } }