Advertisement
silvana1303

email validator

Aug 7th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace _02._Boss_Rush
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string input = Console.ReadLine();
  13.  
  14.             string[] command = Console.ReadLine().Split();
  15.  
  16.             while (command[0] != "Complete")
  17.             {
  18.                 if (command[0] == "Make")
  19.                 {
  20.                     if (command[1] == "Upper")
  21.                     {
  22.                         input = input.ToUpper();
  23.                     }
  24.                     else
  25.                     {
  26.                         input = input.ToLower();
  27.                     }
  28.  
  29.                     Console.WriteLine(input);
  30.                 }
  31.                 if (command[0] == "GetDomain")
  32.                 {
  33.                     int count = int.Parse(command[1]);
  34.  
  35.                     if (count >= 0 && count < input.Length)
  36.                     {
  37.                         char[] reverse = input.TakeLast(count).ToArray();
  38.                         string output = new string(reverse);
  39.                         Console.WriteLine(output);
  40.  
  41.                     }
  42.                     else
  43.                     {
  44.                         Console.WriteLine(input);
  45.                     }
  46.  
  47.                 }
  48.                 if (command[0] == "GetUsername")
  49.                 {
  50.                     if (input.Contains("@"))
  51.                     {
  52.                         int index = input.IndexOf("@");
  53.                         string username = input.Substring(0, index);
  54.                         Console.WriteLine(username);
  55.                     }
  56.                     else
  57.                     {
  58.                         Console.WriteLine($"The email {input} doesn't contain the @ symbol.");
  59.                     }
  60.                 }
  61.                 if (command[0] == "Replace")
  62.                 {
  63.                     input = input.Replace(command[1], "-");
  64.                     Console.WriteLine(input);
  65.                    
  66.                 }
  67.                 if (command[0] == "Encrypt")
  68.                 {
  69.                     char[] email = input.ToCharArray();
  70.  
  71.                     List<int> output = new List<int>();
  72.  
  73.                     foreach (int item in email)
  74.                     {
  75.                         output.Add(item);
  76.                     }
  77.  
  78.                     Console.WriteLine(string.Join(" ", output));
  79.                 }
  80.          
  81.                 command = Console.ReadLine().Split();
  82.             }
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement