title: Generate Alphabetic Pyramid based on user input
body: <p>I'm having trouble with this homework assignment and would like some assistance. I do not want just solutions, as I want to learn from them.</p>
  
  <p>We are doing a letter pyramid using loops.  I can't seem to figure out how to put these FOR loops together to make this work as instructed.  </p>
  
  <p>The user should enter a letter (or other character which gives an error) then the program converts the letter to upper case if not already.  After the conversion to upper case, loops are used in order to go from the character 'A' to whatever the user enters then back to 'A' again.  An example is below.  </p>
  
  <p>I have attached my code that I have come up with but the output of the program should be as below but the lines are supposed to be spaces.  I just added them for spacing:</p>
  
  <p>Enter a single letter (Enter alphabet to display Pyramid): E</p>
  
  <pre><code>____A
  ___ABA
  __ABCBA
  _ABCDCBA
  ABCDEDCBA
  </code></pre>
  
  <p>My output is simply this:</p>
  
  <pre><code>Please enter a single letter:
  f
                      ABCDEFEDCBA
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>import java.util.*; // For using Scanner class for input
  
  public class LetterPyramid {
      public static void main(String[] args) {
          Scanner key = new Scanner(System.in);
          System.out.println("Please enter a single letter:");
          char input = key.next().charAt(0);
          input = Character.toUpperCase(input);
          if (!(Character.isLetter(input))) {
              System.out.println("Error: Invalid letter: " + input);
          } else {
              for (int i = input; i &lt; 'Z'; i++) {
                  System.out.print(" ");
              }
          }
          for (char y = 'A'; y &lt; input; y++) {
              System.out.print(y);
              if (y == input) {
                  System.out.println(y);
              }
          }
          for (char x = input; x &gt;= 'A'; x--) {
              System.out.print(x);
          }
          System.out.println();
      }
  }
  </code></pre>