// Zorah Fung, CSE 142/ // Prompts a user for a message and a "key" and encrypts the message using // a Caesar cipher and the key as the shift value. import java.util.*; public class CaesarCipher { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Your secret message: "); String message = console.nextLine(); message = message.toLowerCase(); System.out.print("Your secret key: "); int key = console.nextInt(); System.out.print("Your encoded message is: "); for (int i = 0; i < message.length(); i++) { char c = message.charAt(i); if (c == ' ') { System.out.print(" "); } else { System.out.print((char) (c + key)); } } System.out.println(); } }