Hello,
I am working on the same code to produce the Hour Glass figure.
My code is a little bit different because I am using a CONSTANT to change the size of the Hour Glass. I have my CONSTANT set to 4. The problem I am having is in my method for the BOTTOM HALF.
I am getting an error message that says this.
What I don't understand is that to me it look like the same as the Top Half but with reverse order so I don't understand why I am getting this error.HourGlass.java:56: error: class, interface, or enum expected public static void drawBottomHalf()
Here is my code.
public class HourGlass { public static final int HEIGHT = 4; public static void main(String[] args) { drawTop(); drawTopHalf(); drawVertical(); drawBottomHalf(); drawTop(); } // Produces the top part of the hour glass public static void drawTop() { System.out.print("|"); for (int i = 1; 1 <= (2 * HEIGHT + 1); i++) { System.out.print("\""); } System.out.println("|"); } // Produces the top half of the hour glass public static void drawTopHalf() { for (int line = 1; line <= HEIGHT; line++) { for (int i = 1; i <= (line-1); i++) { System.out.print(" "); } System.out.print("\\"); int dots = 2 * HEIGHT - 2 * line; for (int i = 1; i <= dots; i++) { System.out.print(":"); } System.out.print("/"); } } // Produces the Vertical two line in the center public static void drawVertical() { System.out.print("|"); System.out.print(" "); system.out.print("|"); } } // Produces the bottom half of the hour glass public static void drawBottomHalf() { for (int line = 1; line <= HEIGHT; line++) { for (int i = 1; i <= (HEIGHT - line); i++) { System.out.print(" "); } System.out.print("/") for (int i = 1; i <= 2 * (line-1); i++) { System.out.print(":"); } System.out.print("\\"); for (int i = 1; i <= (HEIGHT - line); { System.out.print(" "); } } } }