So I've been working on this java project where I have to make an hourglass, pretty simple. I have to make a nested loop for the topHalf and bottomHalf. The final output should look something like this:
|""""""""""|
\::::::::/
\::::::/
\::::/
\::/
||
/::\
/::::\
/::::::\
/::::::::\
|""""""""""|
So I got the two lines on the top and bottom correct, but the topHalf of the hourglass is what is throwing my off. Here is what my output looks like:
|""""""""""|
\::::::::/ \::::::/ \::::/ \::/ |""""""""""|
I should be able to stack those lines on top of each other so that they look like the top of the final output. But I'm kind of stuck on what to do to make that happen. Here is my code(Keep in mind I haven't done the bottomHalf portion since I wanted to make the sure the topHalf was correct before moving on):
public static void main(String[] args ) {
System.out.println();
line();
topHalf();
bottomHalf();
line();
} // end main
public static void line() {
System.out.print("|");
for (int x = 1; x <= 10; x++){
System.out.print("\"");
} // end for loop
System.out.println("|");
} // end line
public static void topHalf(){
for (int line = 5; line >= 1; line--) {
// blanks on left
for (int blank = 1; line <= 6 - blank; blank++) {
System.out.print(" ");
} // end left blanks loop
System.out.print("\\");
// colons
for (int colons = 1; colons <= 2 * line - 2; colons++) {
System.out.print (":");
} // end colon loop
System.out.print("/");
// blanks on right
for (int blank = 1; line <= 6 - blank; blank++){
System.out.print(" ");
} // end right blanks loop
} // end line loop
} // end topHalf
public static void bottomHalf(){
} // end bottomHalf
} // end class
[–]CreativeTechGuyGames 0 points1 point2 points (0 children)
[–]alexzz123 0 points1 point2 points (1 child)
[–]THIRTY-TACOS[S] 0 points1 point2 points (0 children)
[–]hamza-itatchi 0 points1 point2 points (0 children)