Objective
Write a C# program to ask the user for a symbol and respond whether it is a vowel (in lowercase), a digit, or any other symbol, using "switch".
Write Your C# Exercise
C# Exercise Example
using System; // Import the System namespace to use basic classes like Console
class Program // Define the main class of the program
{
static void Main() // The entry point of the program
{
// Ask the user to enter a symbol
Console.Write("Enter a symbol: "); // Display prompt for symbol input
char symbol = Console.ReadKey().KeyChar; // Read a single character input from the user
// Move to the next line after the symbol input
Console.WriteLine();
// Use switch to determine if the symbol is a vowel, digit, or other symbol
switch (symbol)
{
case 'a': // If the symbol is 'a'
case 'e': // If the symbol is 'e'
case 'i': // If the symbol is 'i'
case 'o': // If the symbol is 'o'
case 'u': // If the symbol is 'u'
Console.WriteLine("It is a vowel."); // Display message for vowel
break;
// Check if the symbol is a digit
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
Console.WriteLine("It is a digit."); // Display message for digit
break;
// If the symbol is neither a vowel nor a digit
default:
Console.WriteLine("It is another symbol."); // Display message for other symbols
break;
}
}
}