Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Hourglass Java

public class hello {
  

  public static void main(String[] args) {
    System.out.printf("|""""""""""|
");
    for (int i=1; i<5; i++) {
        //* print leading spaces
        for (int j=0; j<i; j++) {
          System.out.printf(" ");
        }
        //* print single backslash
        System.out.printf("");
        //*print colons (8 for i=1 line, 6 for i = 2, ...)
        for (int j=0; j<10-2*i; j++) {
          System.out.printf(":");
        }
        //* print single forward slash and new line
        System.out.printf("/
");
    }
    //* print middle line
    System.out.printf("     ||     
");
    for (int i=1; i<5; i++) {
        //* print leading spaces ()
        for (int j=0; j<5-i; j++) {
          System.out.printf(" ");
        }
        //* print single backslash
        System.out.printf("/");
        //*print colons (8 for second line, 6 for third, ...)
        for (int j=0; j<2*i; j++) {
          System.out.printf(":");
        }
        //* print single forward slash and newline
        System.out.printf("
");
    }
    
    System.out.printf("|""""""""""|
");
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: running sum of 1d array java 
Java :: java remove space at the end of string 
Java :: print an array java 
Java :: filter arraylist java 
Java :: android imageview set image from drawable programmatically 
Java :: Delete end element in string java 
Java :: How to determine whether a graph contains a cycle, in Java? 
Java :: find number of occurrences of a substring in a string java 
Java :: initial data for list java 
Java :: on selected item changed listview javafx 
Java :: java quit application 
Java :: does finally block executed after crash 
Java :: how to change theme of app in android studio programmatically 
Java :: create java gui intellij 
Java :: java arraylist deepcopy 
Java :: start activity for result deprecate 
Java :: how to make a loop in java 
Java :: redondear a 2 decimales java 
Java :: create a list java 
Java :: java delete column from csv 
Java :: java how to compare strings 
Java :: java integer division tofloat 
Java :: declare class constant array java 
Java :: BST in java 
Java :: reverse in jaav 
Java :: setbackground color hexadecimal android 
Java :: compare numbers in array in java 
Java :: check stack empty java 
Java :: Finding the Sum of an Array in Java 
Java :: java multiple catch blocks 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =