title: How do I print out an hourglass using asterisks?
body: <p>For a homework assignment, I am trying to construct a program that prints an hourglass shape to the screen using asterisks and spaces. I have written the program below, but its output doesn't look anything like an hourglass. Can anyone help me understand why my program isn't producing the expected output? </p>
  
  <pre><code>public class hourglass {
      public static void main(String[] args) {
          int x = Integer.parseInt(args[0]);
          int k = 2 * x - 1;
          int c = k;
  
          for (int j = x; j &gt; 0; j--) {
              for (int f = j; f &lt;= k; f++) {
                  System.out.print("*");
              }
              for (int o = 1; o &lt;= c; o++) {
                  if (k % 2 == 0) System.out.print(" ");
                  else System.out.print(" ");
              }
              System.out.print("\n");
          }
      }
  }
  </code></pre>
  
  <p>EDIT: I redid the program now it just prints into infinity and beyond, I understand the logic that I need to take in a x number and then run a for loop, each and every time I go through it I -1 from the x. 
  Can anyone help me with this please? I'm simply trying to deepen my understanding in Java.</p>
  
  <pre><code>public class hourglass
  {
    public static void main(String[] args)
    { 
      int valueIn = Integer.parseInt(args[0]); 
      int maxVALUE = 2*valueIn ;
  
      for( int i = 0 ;  (valueIn - 1) &gt; i; i--)
      {for( int j =1 ; j &lt; maxVALUE; i++)
        {
  
        System.out.print("*");}
    for (int o = 1; o &lt; maxVALUE; o++) {
      if (maxVALUE % 2 == 0) System.out.print(" ");
      else System.out.print(" ");
     }
     System.out.print("\n");
  
  
  
  
    }
   }
  }
  </code></pre>
  
  <p>EDIT 2* 
  If anyone sees this well, here I go.
  I've constructed a code on my own for the past 8 hours and now I'm stuck, I don't know how I can "reverse" my for loop to make it print into the other direction here's my code, I don't know what to do and if anyone can give me any insight on how to do this I would be very pleased, I tried doing an if case if(i == 0) but that never happens and I even tried making that if case ==1; but then the loop ran forever.
  Any pointers on how to finish my program? </p>
  
  <pre><code>public class mathrandom
  {
    public static void main ( String [] args) 
    {
      int valueIn = Integer.parseInt(args[0]);
  
  
      for ( int i = valueIn;  1  &lt;= i; i--){
        for ( int k = i ; k &lt; 2*valueIn -1; k++)
        {System.out.print(" ");}
        {for ( int j = 1; j &lt;= (i*2)-1; j++)
          {
          System.out.  print("*");
  
  
        }
  
          System.out.println();  
      }
  
  }
  
  
    }}
  </code></pre>