Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P01._Email_Validator
  4. {
  5.     class StratUp
  6.     {
  7.         static void Main()
  8.         {
  9.             string email = Console.ReadLine();
  10.             string command = Console.ReadLine();
  11.  
  12.             while (command != "Complete")
  13.             {
  14.                 string[] split = command.Split();
  15.                 if (command == "Make Upper")
  16.                 {
  17.                     email = email.ToUpper();
  18.                     Console.WriteLine(email);
  19.                 }
  20.                 if (command == "Make Lower")
  21.                 {
  22.                     email = email.ToLower();
  23.                     Console.WriteLine(email);
  24.                 }
  25.                 if (command.Contains("GetDomain"))
  26.                 {
  27.                     int count = int.Parse(split[1]);
  28.                     string domain = email.Substring(email.Length - count, count);
  29.                     Console.WriteLine(domain);
  30.                 }
  31.                 if (command.Contains("Replace"))
  32.                 {
  33.                     char replace = char.Parse(split[1]);
  34.                     email = email.Replace(replace, '-');
  35.                     Console.WriteLine(email);
  36.                 }
  37.                 if (command.Contains("Encrypt"))
  38.                 {
  39.                     for (int i = 0; i < email.Length; i++)
  40.                     {
  41.                         Console.Write($"{(int)email[i]} ");
  42.                     }
  43.  
  44.                     Console.WriteLine();
  45.                 }
  46.                 if (command.Contains("GetUsername"))
  47.                 {
  48.                     int index = email.IndexOf("@");
  49.                     if (index < 0)
  50.                     {
  51.                         Console.WriteLine($"The email {email} doesn't contain the @ symbol.");
  52.                     }
  53.                     else
  54.                     {
  55.                         Console.WriteLine(email.Substring(0, index));
  56.                     }
  57.                 }
  58.  
  59.                 command = Console.ReadLine();
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement