Counting Vowels



Count Vowels

This is a C# program I really enjoyed making. It counts the numbers of vowels in any word you enter. Cool stuff!

Here's the code!

                            using System;
                            namespace CountVowelsModularized
                            {
                                class CountVowelsModularized
                                {
                                    static void Main(string[] args)
                                    {
                                        Console.Write("Enter a word: ");
                                        string word = Console.ReadLine().ToLower();
                                        Console.WriteLine("The number of vowels in your word is: {0}", countVowels(word));
                                        Console.ReadLine();
                                    }

                                    public static int countVowels (string word)
                                    {
                                        int vowelCounter = 0;
                                        for (int x = 0; x < word.Length; x++)
                                        {
                                            if (word[x] == 'a' || word[x] == 'e' || word[x] == 'i' || word[x] == 'o' || word[x] == 'u')
                                            {
                                                vowelCounter++;
                                            }
                                        }
                                        return vowelCounter;
                                    }
        
                                }
                            }