I am trying to code in C# and ran into this problem that says I need to count how many vowel/s there is/are in the entered string. It only identifies the first letter. Here is the program:
class CountVowelsModularized
{
public static void Main()
{
// Write your main here.
string word;
WriteLine("Enter a word");
word=ReadLine().ToUpper();
WriteLine("This word has {0} vowels", CountVowels(word));
}
public static int CountVowels(string phrase)
{
// Write your CounVowels method here.
int vowel_count=0;
int i=0;
for(i=0;i<phrase.Length;i++)
{
if(phrase[i]=='A'||phrase[i]=='E'||phrase[i]=='I'||phrase[i]=='O'||phrase[i]=='U')
{
vowel_count++;
++;
}
else
i++;
}
return vowel_count;
}
}