title: Print cross pattern in Java
body: <p>I've got this homework exercise that I'm stuck on. </p>
  
  <p>Basically we have to print a cross pattern with 'X' character, but the middle bit has to be empty. </p>
  
  <p>So, the program has to read an integer from the command line and after executing it it should output a cross pattern.</p>
  
  <p>Something like this:
  <code> 
          x 
          x
          x
    x x x   x x x
          x
          x
          x</code></p>
  
  <p>Hopefully you can see it formatted properly above, basically I don't how to add that empty bit in the middle.</p>
  
  <p>This is what I have so far:
  <code>
  public class Cross {</p>
  
  <pre><code>public static void main(String[] args) {
  int num = 0;
  for (int i = 0; i &lt; args.length; i++) 
  {
    num = Integer.parseInt(args[i]);
      drawCross(num);
  }
  }
  
  
  public static void drawCross(int num){
  
   for(int i = 0; i &lt; num; i++) 
   {
          for(int j = 0; j &lt; num; j++) 
          {
  
              if((i == num / 2) || (j == num / 2)) 
                  System.out.print("X ");
  
              else 
                 System.out.print(" ");
                 System.out.print(" ");
  
      }
      System.out.println();
          }
  
  }
  }
  </code></pre>
  
  <p></code>     </p>
  
  <p>Now, this above works, but it prints a normal cross, without the gap in the middle. (Also, I'm guessing that there's a smarter way of doing this instead of using sysout)</p>
  
  <p>The only other requirements that they gave us are that the 'x' should be printed <i>4n</i> times and that the program must handle invalid inputs.</p>
  
  <p>I would appreciate if you guys can give me a hand!
  Cheers</p>