107 303
Assignments Done
98.9%
Successfully Done
In March 2023

# Answer to Question #238489 in C# for Gayatri

Question #238489
Take input of a string from user and convert it into piglatin.

Description

1. Take console input of a string, in Main () method from user.

2. Pass the string to method 'string ConvertStringToPiglatin(string sourceStr)' and write

I

the logic in that method to convert the source string piglatin form. 3. Return the result string from string ConvertStringToPiglatin(string sourceStr)' to

Main() and display the result string.

If vowels existed in the source string, returns valid piglatin string Example: source string: techademy, piglatin form: 'echademytay

i.e. split the source string up to the 1st vowel index and place that part at the end

of source string. And finally append the 'ay to the result string

Else returns "-1" 4 Use Subfunction to check if source string has Vowels: 'bool IsVowelExisted (string

source)'.
1
2021-09-17T11:31:00-0400
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: ");
Console.WriteLine("Text translation: ");
Console.WriteLine(ConvertStringToPiglatin(sourceStr));
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!