Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package FinalExam.O1;
- import java.util.Scanner;
- public class O1TheImitationGame {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- StringBuilder input = new StringBuilder(scanner.nextLine());
- String command = scanner.nextLine();
- while (!command.equals("Decode")) {
- String[] type = command.split("\\|");
- switch (type[0]) {
- case "Insert":
- input.insert(Integer.parseInt(type[1]), type[2]);
- break;
- case "ChangeAll":
- input = new StringBuilder(input.toString().replace(type[1], type[2]));
- break;
- case"Move":
- input = new StringBuilder(input.substring(Integer.parseInt(type[1])) +
- input.substring(0, Integer.parseInt(type[1])));
- break;
- }
- command = scanner.nextLine();
- }
- System.out.println("The decrypted message is: " + input);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment