Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Playing
- {
- class Program
- {
- static void Main(string[] args)
- {
- string username = Console.ReadLine();
- string command = Console.ReadLine();
- while (command != "Sign up")
- {
- string[] tokens = command.Split().ToArray();
- if (tokens[0] == "Case")
- {
- if (tokens[1] == "lower")
- {
- username = username.ToLower();
- Console.WriteLine(username);
- }
- else if (tokens[1] == "upper")
- {
- username = username.ToUpper();
- Console.WriteLine(username);
- }
- }
- else if (tokens[0] == "Reverse")
- {
- string reversed = string.Empty;
- int startIndex = int.Parse(tokens[1]);
- int endIndex = int.Parse(tokens[2]);
- for (int i = endIndex; i > startIndex - 1; i--)
- {
- reversed += username[i];
- }
- Console.WriteLine(reversed);
- }
- else if (tokens[0] == "Cut")
- {
- if (username.Contains(tokens[1]))
- {
- int index = username.IndexOf(tokens[1]);
- username = username.Remove(index,tokens[1].Length);
- Console.WriteLine(username);
- }
- else
- {
- Console.WriteLine($"The word {username} doesn't contain {tokens[1]}.");
- }
- }
- else if (tokens[0] == "Replace")
- {
- char oldChar = char.Parse(tokens[1]);
- username = username.Replace(oldChar, '*');
- Console.WriteLine(username);
- }
- else if (tokens[0] == "Check")
- {
- if (username.Contains(tokens[1]))
- {
- Console.WriteLine("Valid");
- }
- else
- {
- Console.WriteLine($"Your username must contain {tokens[1]}.");
- }
- }
- command = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment