Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace FFE
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string command = Console.ReadLine();
- while (command != "Finish")
- {
- string[] splitted = command.Split();
- if (command.Contains("Replace"))
- {
- string currentString = (splitted[1]);
- string newString = (splitted[2]);
- input = input.Replace(currentString, newString);
- Console.WriteLine(input);
- }
- else if (command.Contains("Cut"))
- {
- int startIndex = int.Parse(splitted[1]);
- int endIndex = int.Parse(splitted[2]);
- if (startIndex >= 0 && endIndex < input.Length)
- {
- input = input.Remove(startIndex, endIndex - startIndex + 1);
- Console.WriteLine(input);
- }
- else
- {
- Console.WriteLine("Invalid indexes!");
- }
- }
- else if (command.Contains("Upper"))
- {
- input = input.ToUpper();
- Console.WriteLine(input);
- }
- else if (command.Contains("Lower"))
- {
- input = input.ToLower();
- Console.WriteLine(input);
- }
- else if (command.Contains("Check"))
- {
- string toCheck = splitted[1];
- if (input.Contains(toCheck))
- {
- Console.WriteLine($"Message contains {toCheck}");
- }
- else
- {
- Console.WriteLine($"Message doesn't contain {toCheck}");
- }
- }
- else if (command.Contains("Sum"))
- {
- int startIndex = int.Parse(splitted[1]);
- int endIndex = int.Parse(splitted[2]);
- if (startIndex >= 0 && endIndex < input.Length)
- {
- string toSum = input.Substring(startIndex, endIndex - startIndex + 1);
- int sum = 0;
- for (int i = 0; i < toSum.Length; i++)
- {
- sum += toSum[i];
- }
- Console.WriteLine(sum);
- }
- else
- {
- Console.WriteLine("Invalid indexes!");
- }
- }
- command = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement