Advertisement
Guest User

Email Validator

a guest
Mar 21st, 2020
880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Email_Validator
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string email = Console.ReadLine();
  13.  
  14. string command = "";
  15.  
  16. while ((command = Console.ReadLine()) != "Complete")
  17. {
  18.  
  19. string[] commArgs = command.Split().ToArray();
  20.  
  21. switch (commArgs[0])
  22. {
  23. case "Make":
  24.  
  25. if (commArgs[1] == "Upper")
  26. {
  27. email = email.ToUpper();
  28. }
  29. else if (commArgs[1] == "Lower")
  30. {
  31. email = email.ToLower();
  32. }
  33. Console.WriteLine(email);
  34. break;
  35.  
  36. case "GetDomain":
  37. int count = int.Parse(commArgs[1]);
  38.  
  39. if (count < email.Length && count >= 0)
  40. {
  41. Console.WriteLine(email.Substring(email.Length - count));
  42. }
  43. else
  44. {
  45. Console.WriteLine(email);
  46. }
  47. break;
  48.  
  49. case "GetUsername":
  50. if (email.Contains('@'))
  51. {
  52. int indexOfAt = email.IndexOf('@');
  53. string username = email.Substring(0,indexOfAt);
  54. Console.WriteLine(username);
  55. }
  56. else
  57. {
  58. Console.WriteLine($"The email {email} doesn't contain the @ symbol.");
  59. }
  60. break;
  61.  
  62. case "Replace":
  63. char currentCh = char.Parse(commArgs[1]);
  64. email = email.Replace(currentCh, '-');
  65. Console.WriteLine(email);
  66. break;
  67.  
  68. case "Encrypt":
  69. for (int i = 0; i < email.Length; i++)
  70. {
  71. char currSumbol = email[i];
  72. Console.Write((int)currSumbol + " ");
  73. }
  74. Console.WriteLine();
  75. break;
  76. }
  77.  
  78. }
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement