Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class lqlq {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String email = sc.nextLine();
- String commands = sc.nextLine();
- while (!commands.equals("Complete")) {
- String[] command = commands.split("\\s+");
- String cases = command[0];
- switch (cases) {
- case "Make":
- String secondCommand = command[1];
- if (secondCommand.equals("Upper")) {
- email = email.toUpperCase();
- System.out.println(String.format(email));
- }
- if (secondCommand.equals("Lower")) {
- email = email.toLowerCase();
- System.out.println(String.format(email));
- }
- break;
- case "GetDomain"://<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- int count = Integer.parseInt(command[1]);
- String empty = "";
- if(count>=0 && count<=email.length()-1) {
- for (int i = email.length() - (count); i <= email.length() - 1; i++) {
- char letter = email.charAt(i);
- empty += letter;
- }
- }
- System.out.println(String.format(empty));
- break;
- case "GetUsername":
- String experiment = email;
- if(experiment.contains("@")) {
- int index = experiment.indexOf('@');
- experiment = experiment.substring(0, index);
- System.out.println(String.format(experiment));
- }else{
- System.out.println(String.format
- ("The email %s doesn't contain the @ symbol.",email));
- }
- break;
- case "Replace":
- char symbol = command[1].charAt(0);
- char newSymbol = '-';
- StringBuilder tempString = new StringBuilder(email);
- for (int i=0;i<=email.length()-1;i++) {
- int index=email.indexOf(symbol);
- tempString.setCharAt(index,newSymbol);
- email = tempString.toString();
- }
- System.out.println(String.format(email));
- break;
- case "Encrypt":
- for(int i=0;i<=email.length()-1;i++){
- char toCast=email.charAt(i);
- int value=(int)toCast;
- System.out.print(String.format("%d ",value));
- }
- break;
- }
- commands = sc.nextLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement