static string repvowel(string str)
{
char[] vowels = {'a','e','i','o','u'};
List<char> a1 = vowels.OfType<char>().ToList(); ;
StringBuilder sb = new StringBuilder(str);
for (int i = 0; i < sb.Length; i++)
{
if (a1.Contains(sb[i]))
{
sb.Replace(sb[i].ToString(),"%");
i--;
}
}
return sb.ToString();
}
static string repcons(string cons)
{
char[] word2 = cons.ToCharArray();
for (int j = 0; j < word2.Length; j++)
{
if (word2[j] != 'a' &&
word2[j] != 'e' &&
word2[j] != 'i' &&
word2[j] != 'o' &&
word2[j] != 'u')
{
word2[j] = '#';
}
}
return new string(word2);
}
public static string upper(string cas)
{
char[] word3 = cas.ToCharArray();
for (int l = 0; l < word3.Length; l++)
{
char ch = word3[l];
if (Char.IsLower(ch))
char.ToUpper(ch);
else
char.ToString(ch);
}
return new string(word3);
}
public static void Main()
{
Console.WriteLine("enter first word");
string str = Console.ReadLine();
Console.WriteLine("enter second word");
string cons = Console.ReadLine();
Console.WriteLine("enter third word");
string cas = Console.ReadLine();
Console.Write(repvowel(str));
Console.Write(repcons(cons));
Console.Write(upper(cas));
Console.ReadKey();
}
What I have tried:
static string repvowel(string str)
{
char[] vowels = {'a','e','i','o','u'};
List<char> a1 = vowels.OfType<char>().ToList(); ;
StringBuilder sb = new StringBuilder(str);
for (int i = 0; i < sb.Length; i++)
{
if (a1.Contains(sb[i]))
{
sb.Replace(sb[i].ToString(),"%");
i--;
}
}
return sb.ToString();
}
static string repcons(string cons)
{
char[] word2 = cons.ToCharArray();
for (int j = 0; j < word2.Length; j++)
{
if (word2[j] != 'a' &&
word2[j] != 'e' &&
word2[j] != 'i' &&
word2[j] != 'o' &&
word2[j] != 'u')
{
word2[j] = '#';
}
}
return new string(word2);
}
public static string upper(string cas)
{
char[] word3 = cas.ToCharArray();
for (int l = 0; l < word3.Length; l++)
{
char ch = word3[l];
if (Char.IsLower(ch))
char.ToUpper(ch);
else
char.ToString(ch);
}
return new string(word3);
}
public static void Main()
{
Console.WriteLine("enter first word");
string str = Console.ReadLine();
Console.WriteLine("enter second word");
string cons = Console.ReadLine();
Console.WriteLine("enter third word");
string cas = Console.ReadLine();
Console.Write(repvowel(str));
Console.Write(repcons(cons));
Console.Write(upper(cas));
Console.ReadKey();
}