Advertisement
Guest User

Untitled

a guest
Mar 30th, 2025
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.78 KB | None | 0 0
  1. namespace _1__
  2. {
  3.     internal class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             string input = Console.ReadLine();
  8.             string command = string.Empty;
  9.             while ((command = Console.ReadLine()) != "Registration")
  10.             {
  11.                 string[] cmd = command.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
  12.                 switch (cmd[0])
  13.                 {
  14.                     case "Letters":
  15.                         if (cmd[1] == "Upper")
  16.                         {
  17.                             input = input.ToUpper();
  18.                         }
  19.                         else
  20.                         {
  21.                             input = input.ToLower();
  22.                         }
  23.                         Console.WriteLine(input);
  24.                         break;
  25.                     case "Reverse":
  26.                         int startInx = int.Parse(cmd[1]);
  27.                         int endInx = int.Parse(cmd[2]);
  28.                         if (startInx >= 0 && endInx < input.Length && startInx <= endInx)
  29.                         {
  30.                             Console.WriteLine(string.Join("", input.Substring(startInx, (endInx - startInx + 1)).Reverse()));
  31.                         }
  32.                         break;
  33.                     case "Substring":
  34.                         if (input.Contains(cmd[1]))
  35.                         {
  36.                             while (input.Contains(cmd[1]))
  37.                             {
  38.                                 input = input.Remove(input.IndexOf(cmd[1]), cmd.Length);
  39.                                 Console.WriteLine(input);
  40.                             }
  41.                         }
  42.                         //input = input.Replace(cmd[1], "");
  43.                         else
  44.                         {
  45.                             Console.WriteLine($"The username {input} doesn't contain {cmd[1]}.");
  46.                         }
  47.                         break;
  48.  
  49.                     case "Replace":
  50.                         if (input.Contains(cmd[1]))
  51.                         {
  52.                             input = input.Replace(cmd[1], "-");
  53.                             Console.WriteLine(input);
  54.                         }
  55.                         break;
  56.                     case "IsValid":
  57.                         if (input.Contains(cmd[1]))
  58.                         {
  59.                             Console.WriteLine("Valid username.");
  60.                         }
  61.                         else
  62.                         {
  63.                             Console.WriteLine($"{cmd[1]} must be contained in your username.");
  64.                         }
  65.                         break;
  66.                     default:
  67.                         break;
  68.                 }
  69.             }
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement