using System;
namespace ConsoleApp
{
class Program
{
public static bool IsVowelExisted(string argStr)
{
foreach (var letter in argStr)
{
if ("AUEOIaueoi".Contains(letter))
{
return true;
}
}
return false;
}
public static string ConvertStringToPiglatin(string sourseStr)
{
string temp = "";
// break into words
string[] words = sourseStr.Split();
for (int i = 0; i < words.Length; i++)
{
if (IsVowelExisted(words[i]))
{
for (int j = 0; j < words[i].Length; j++)
{
if ("AUEOIaueoi".Contains(words[i][j]))
{
temp = words[i].Substring(j, words[i].Length - j) + words[i].Substring(0, j) + "ay";
words[i] = temp;
break;
}
}
}
}
return string.Join(" ", words);
}
static void Main(string[] args)
{
Console.Write("Enter the text: ");
string sourceStr = Console.ReadLine();
Console.WriteLine("Text translation: ");
Console.WriteLine(ConvertStringToPiglatin(sourceStr));
}
}
}
Comments
Leave a comment