desislava_topuzakova

04. Caesar Cipher

Mar 14th, 2021
870
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.Locale;
  2. import java.util.Scanner;
  3.  
  4. public class demo {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.        String sentence = scanner.nextLine();
  8.        StringBuilder encryptedSentence = new StringBuilder();
  9.  
  10.         for (int index = 0; index <= sentence.length() - 1; index++) {
  11.             char currentSymbol = sentence.charAt(index);
  12.             encryptedSentence.append((char)(currentSymbol + 3));
  13.         }
  14.  
  15.         System.out.println(encryptedSentence.toString());
  16.  
  17.  
  18.     }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment