Programming Course in C# ¡Free!

Vowel - switch

 Saturday, April 06, 2013 published by Exercises C#
Proposed exercise

Create a program to ask the user for a symbol and answer if it is a (lowercase) vowel, a digit, or any other symbol, using "switch".


Output



Solution


using System;
public class SwitchVowel
{
public static void Main()
{
char symbol;

Console.Write("Enter a symbol: ");
symbol=Convert.ToChar(Console.ReadLine());

switch(symbol)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
Console.WriteLine("It's a lowercase vowel.");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
Console.WriteLine("It's a digit.");
break;
default:
Console.Write("It's another symbol.");
break;
}
}
}