SophiYo

Demo Exam(Deciphering)

Apr 17th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. package Demo0604Exam;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class proba {
  6.  
  7.         public static void main(String[] args) {
  8.             Scanner scanner = new Scanner(System.in);
  9.  
  10.             String input = scanner.nextLine();
  11.  
  12.             String[] substringArr = scanner.nextLine().split("\\s+");
  13.  
  14.             for (int i = 0; i < input.length(); i++) {
  15.                 int letter = input.charAt(i);
  16.                 if(letter != 35) {
  17.                     if (letter < 100 || letter > 125) {
  18.                         System.out.println("This is not the book you are looking for.");
  19.                         return;
  20.                     }
  21.                 }
  22.             }
  23.  
  24.             String word = "";
  25.             for (int i = 0; i < input.length(); i++) {
  26.                 int letter = input.charAt(i);
  27.                 int letterF = letter - 3;
  28.                 word += (char)letterF;
  29.             }
  30.  
  31.                 word = word.replace(substringArr[0], substringArr[1]);
  32.                 System.out.println(word);
  33.  
  34.         }
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment