package class1_2_Caesar; import java.util.Scanner; /** * Created by yoder on 12/1/2016. */ public class CaesarCipher { public static void main(String[] args) { System.out.println("Please enter a string to encrypt:"); Scanner in = new Scanner(System.in); String line = in.nextLine(); System.out.println("Please enter the offset:"); String keyString = in.nextLine(); int key = new Scanner(keyString).nextInt(); System.out.println("line = " + line); System.out.println("key = " + key); String ciphertext = ""; for(int i = 0; i < line.length(); i++) { char c = line.charAt(i); System.out.println("c = " + c); // if(c >= 'a' && c <= 'z' // || c >= 'A' && c <= 'Z') { c = (char) (c + key); // } ciphertext += c; } System.out.println("ciphertext = " + ciphertext); // from earlier // // TODO // char c = line.charAt(0); // System.out.println("c = " + c); // System.out.println("(int)c = " + (int) c); // System.out.println("c + 1 = " + (c + 1)); // char d = (char) (c + 1); //// char nextLetter = (int)c; // System.out.println("d = " + d); } }