Finding if an alphabet is Vowel or Not using Switch Case

Finding is an alphabet is Vowel or not using Switch...Case..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VowelMatch
{
    class Program
    {
        static void Main(string[] args)
        {  
            Console.WriteLine("Enter a single alphabet : ");
            //Convert the alphabet to lowercase so that the Switch Case works even when uppercase
            //or lowercase alphabets are given          
            char alphabet = Convert.ToChar(Console.ReadLine().ToLowerInvariant());
            string finalmessage;
            switch (alphabet)
            {
                case 'a' :
                    finalmessage = "an Vowel";
                    break;
                case 'e':
                    finalmessage = "an Vowel";
                    break;
                case 'i':
                    finalmessage = "an Vowel";
                    break;
                case 'o':
                    finalmessage = "an Vowel";
                    break;
                case 'u':
                    finalmessage = "an Vowel";
                    break;
                default :
                    finalmessage = "not a Vowel";
                    break;                   
            }
            Console.WriteLine("Alphabet {0} is {1}",alphabet,finalmessage);
            Console.ReadLine();
        }
    }
}

Output:


No comments: