eternalmeg

05. Decrypting Message

May 29th, 2022 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. package dataTypesAndVariablesExerciseMoreExercise;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class DecryptingMessages {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.         byte key = Byte.parseByte(scan.nextLine());
  9.         byte n = Byte.parseByte(scan.nextLine());
  10.  
  11.         for (int i = 0; i < n; i++) {
  12.             char currentSymbol = scan.nextLine().charAt(0);
  13.             int representation = (int)currentSymbol;
  14.             int decryption = representation+key;
  15.             char symbol = (char)decryption;
  16.             System.out.print(symbol);
  17.  
  18.         }
  19.     }
  20. }
  21.  
Add Comment
Please, Sign In to add comment