Advertisement
SIRAKOV4444

Untitled

Apr 3rd, 2020
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class lqlq {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6.  
  7. String email = sc.nextLine();
  8. String commands = sc.nextLine();
  9.  
  10. while (!commands.equals("Complete")) {
  11. String[] command = commands.split("\\s+");
  12. String cases = command[0];
  13. switch (cases) {
  14. case "Make":
  15. String secondCommand = command[1];
  16. if (secondCommand.equals("Upper")) {
  17. email = email.toUpperCase();
  18. System.out.println(String.format(email));
  19. }
  20. if (secondCommand.equals("Lower")) {
  21. email = email.toLowerCase();
  22. System.out.println(String.format(email));
  23. }
  24. break;
  25. case "GetDomain"://<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  26. int count = Integer.parseInt(command[1]);
  27. String empty = "";
  28. if(count>=0 && count<=email.length()-1) {
  29. for (int i = email.length() - (count); i <= email.length() - 1; i++) {
  30. char letter = email.charAt(i);
  31. empty += letter;
  32. }
  33. }
  34. System.out.println(String.format(empty));
  35. break;
  36. case "GetUsername":
  37. String experiment = email;
  38. if(experiment.contains("@")) {
  39. int index = experiment.indexOf('@');
  40. experiment = experiment.substring(0, index);
  41. System.out.println(String.format(experiment));
  42. }else{
  43. System.out.println(String.format
  44. ("The email %s doesn't contain the @ symbol.",email));
  45. }
  46. break;
  47. case "Replace":
  48. char symbol = command[1].charAt(0);
  49. char newSymbol = '-';
  50. StringBuilder tempString = new StringBuilder(email);
  51. for (int i=0;i<=email.length()-1;i++) {
  52.  
  53. int index=email.indexOf(symbol);
  54. tempString.setCharAt(index,newSymbol);
  55. email = tempString.toString();
  56. }
  57. System.out.println(String.format(email));
  58. break;
  59. case "Encrypt":
  60. for(int i=0;i<=email.length()-1;i++){
  61. char toCast=email.charAt(i);
  62. int value=(int)toCast;
  63. System.out.print(String.format("%d ",value));
  64. }
  65. break;
  66. }
  67.  
  68.  
  69. commands = sc.nextLine();
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement