title: Get letter from user and print out letter with its position in the alphabet
body: <p>I want to have the user input a letter, and then print out the letter and its position in the alphabet. If the input isn't a letter, I want the program to print: <code>"Not valid"</code>.</p>
  
  <p>How would I do that?</p>
  
  <p>EDIT - Sorry for my unresponsiveness, I actually figured this out a few days ago. Heres the actual code though : </p>
  
  <pre><code>import java.util.Scanner;
  
  public class AlphaPos {
     public static void main(String[] args) {
     java.util.Scanner input = new java.util.Scanner(System.in);
        System.out.println(" Please enter an upper or lowercase letter. ");
             String letter = input.nextLine();
  
             String alpha = " abcdefghijklmnopqrstuvwxyz";
             String beta = " ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
           if((!alpha.contains(letter))&amp;&amp;(!beta.contains(letter))) 
                System.out.println(" You entered " +letter+ ", and you obviously can't follow directions."); 
  
          boolean hasUppercase = !letter.equals(letter.toLowerCase()); {
             if (hasUppercase) 
                System.out.println("Your letter is " +letter+ ", Uppercase, and its number is "+ beta.indexOf(letter));
  
          boolean hasLowercase = !letter.equals(letter.toUpperCase());
             if (hasLowercase)
                   System.out.println("Your letter is " +letter+ " ,lowercase , and its number is "+ alpha.indexOf(letter));
                                                                        }   
  
     }
  }
  </code></pre>
  
  <p>School assignment, so this code has no purpose. And thanks for all the responses anyways!</p>