Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ActivationKeys {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- while (true) {
- String[] commands = scanner.nextLine().split(">>>");
- if (commands[0].equals("Generate")) {
- break;
- }
- switch (commands[0]) {
- case "Contains":
- String substring = commands[1];
- if (input.contains(substring)) {
- System.out.println(String.format("%s contains %s", input, substring));
- } else {
- System.out.println("Substring not found!");
- }
- break;
- case "Flip":
- int startIndex = Integer.parseInt(commands[2]);
- int endIndex = Integer.parseInt(commands[3]);
- if (commands[1].equals("Upper")) {
- String inp1 = input.substring(startIndex, endIndex).toUpperCase();
- String inp2 = input.substring(0, startIndex);
- String inp3 = input.substring(endIndex, input.length());
- input = inp2 + inp1 + inp3;
- System.out.println(input);
- } else if (commands[1].equals("Lower")) {
- String inp1 = input.substring(startIndex, endIndex).toLowerCase();
- String inp2 = input.substring(0, startIndex);
- String inp3 = input.substring(endIndex, input.length());
- input = inp2 + inp1 + inp3;
- System.out.println(input);
- }
- break;
- case "Slice":
- int startInd = Integer.parseInt(commands[1]);
- int endInd = Integer.parseInt(commands[2]);
- input = input.substring(0, startInd) + input.substring(endInd, input.length());
- System.out.println(input);
- break;
- default:
- break;
- }
- }
- System.out.println(String.format("Your activation key is: %s", input));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement