Advertisement
psi_mmobile

Untitled

Dec 1st, 2022
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public class MyClass {
  2. public static void main(String args[]) {
  3. java.util.Scanner scanner = new java.util.Scanner(System.in);
  4. String firstInput = scanner.nextLine();
  5. String currentInput = "";
  6. while(true) {
  7. currentInput = scanner.nextLine();
  8. if(currentInput.equals("Decode")) {
  9. System.out.printf("The decrypted message is: %s",firstInput);
  10. break;
  11. //to-do
  12. }
  13. String[] stringArr = currentInput.split("\\|");
  14. switch(stringArr[0]) {
  15. case "Move" : String p1 = firstInput.substring(0,Integer.parseInt(stringArr[1])); firstInput = firstInput.substring(Integer.parseInt(stringArr[1])) + p1; break;
  16. case "Insert" : String p2 = firstInput.substring(0,Integer.parseInt(stringArr[1])); firstInput = p2 + stringArr[2] + firstInput.substring(Integer.parseInt(stringArr[1])); break;
  17. case "ChangeAll" : firstInput = firstInput.replaceAll(stringArr[1],stringArr[2]); break;
  18. }
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement