/* A program which implements Caesar's cipher */ import java.io.*; //This is the java input output library public class Caesar { /*This is the main program.*/ public static void main(String[] args) throws IOException { BufferedReader in =new BufferedReader(new InputStreamReader(System.in)); //reader for keyboard int key=22; //I have chosen 22 to be my key value but you can change this to any value between 0 and 25 System.out.println("Enter your plaintext: "); String s=in.readLine(); // string s now contains the plaintext System.out.println(); System.out.println(); for(int i=0;i64 && current<91) //if the character is an upper case letter { current=current+key; //add the key value onto the ASCII value if(current>90) current=current-26; //if we've come off the end of the alphabet then we loop } //back around by subtracting 26. else if(current>96 && current<123) //if the character is a lower case letter { current=current+key; if(current>122)current=current-26; } System.out.print((char)(current)); //now we print out the encrypted character or if the character }System.out.println(); //was not a letter then we print the original character. } }