// CS7 // Intermediate test program. // import tio.*; class testCipher { public static void main(String[] args) { char c = ' '; while (c != '%') { System.out.print("Enter a char: "); c = (char) Console.in.readChar(); System.out.println("You entered: " + c); System.out.println("The encrypted values are: "); for (int i=0; i<26; i++) System.out.print((char) caeserCipher(Character.toUpperCase(c), i)); System.out.println(); Console.in.readLine(); // flush buffer of '\n' } }// end main() // transforms an upper case char into a new one by shifting by // key spaces (it wraps around if 'Z' is reached) public static int caeserCipher(char c, int key) { return (c - 'A' + key) % 26 + 'A'; } }// end class