title: Java Cipher Shifting Letters
body: <p>I am currently trying to code a basic encryption program. I have it working, for the most part. It is just not quite working as I'd like. 
  Basically, the user enters a phrase, a shift amount (e.g 5, being 5 letters forwards), and the program encrypts the phrase. 
  For example, if the user entered "red" with a shift of 5, the program should print out: WJI
  However, I got the program to work with the Unicode, so it is printing out the corresponding Unicode characters, so I am getting symbols, such as "{, :" in my encryption. It still works, mind you, but just not the way I am looking for. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>import javax.swing.*;
  public class SimpleEncryption {
  
  /**
   * @param args the command line arguments
   */
  static int shift;
  public static void main(String[] args) {
     String cipher = JOptionPane.showInputDialog(null, "Please enter a sentence or word that you wish to encode or decode. This program uses"
             + " a basic cipher shift.");
    String upperCase = cipher.toUpperCase();
     char[] cipherArray = cipher.toCharArray(); 
     String rotationAmount = JOptionPane.showInputDialog(null, "Please enter a shift amount.");
     int rotation = Integer.parseInt(rotationAmount);
     String encryptOrDecrypt = JOptionPane.showInputDialog(null, "Please choose whether to encrypt or decrypt this message. \n"
             + "Encrypt - press 1\nDecrypt - press 2");
     int choice = Integer.parseInt(encryptOrDecrypt);
     int cipherLength = cipherArray.length;
  
     if (choice == 1) { //if the user chooses to encrypt their cipher
         System.out.println("The original phrase is: "+upperCase);
         System.out.println("ENCRYPTED PHRASE:");
         for (int i = 0; i &lt; cipherLength; i++) {
         shift = (upperCase.charAt(i) + rotation);
         System.out.print((char)(shift));
         }
         System.out.println(" ");
     }
         else if (choice == 2) {
            System.out.println("DECRYPTED PHRASE:");
                 for (int i = 0; i &lt; cipherLength; i++) {
                    shift = (cipher.charAt(i) - rotation);
                     System.out.print((char)(shift));
                 }
  
  
                 }
  
  
     }
  </code></pre>
  
  <p>}</p>
  
  <p>Any and all suggestions are appreciated. Also, lets say the user enters a shift value of 25. How do I get the alphabet to "loop" around. E.g the letter is Z with a shift of 2 would make it "B"? </p>