Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CaesarCipher {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String decryptedText = scanner.nextLine();
- StringBuilder encryptedText = new StringBuilder();
- for (char symbol : decryptedText.toCharArray()) {
- char encryptedSymbol = (char) (symbol + 3);
- encryptedText.append(encryptedSymbol);
- }
- System.out.println(encryptedText);
- }
- }
- /* String decryptedText = scanner.nextLine();
- String encryptedText = "";
- for (char symbol : decryptedText.toCharArray()) {
- char encryptedSymbol = (char)(symbol + 3);
- encryptedText += encryptedSymbol;
- }
- System.out.println(encryptedText);
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment