title: Java Tree Program
body: <p>I need to create a tree program using Java. I am unable to do this and ran out of ideas. It should use a for-loop and substring. Here is an example for a "sample" string:</p>
  
  <pre><code>          S
           SAS
          SAMAS
         SAMPMAS
        SAMPLPMAS
       SAMPLELPMAS
            S
            A
            M
            P 
            L
            E
  </code></pre>
  
  <p>Here is what i have got so far:</p>
  
  <pre><code>    Scanner input = new Scanner(System.in);
  
      String userWord, reverse = "";
      int size;
  
      System.out.print("Enter a word that is less than or equal to 10 characters: ");
      userWord = input.next();
  
      userWord = userWord.toUpperCase();
  
      size = userWord.length()-1;
  
      for (int i = 1; i &lt;= userWord.length() + 1; i++) {
          System.out.print(userWord.substring(0, i));
          System.out.println(userWord.substring(0,i-1));
      }
  </code></pre>
  
  <p>Thanks for any help.</p>