Objective
Write a C# program to ask the user for a symbol and answer if is an uppercase vowel, a lowercase vowel, a digit or any other symbol, using "if".
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 the symbol input
char symbol = Console.ReadKey().KeyChar; // Read the symbol entered by the user
// Check if the symbol is an uppercase vowel
if ("AEIOU".IndexOf(symbol) >= 0) // If the symbol is in the string "AEIOU"
{
Console.WriteLine("\nThe symbol is an uppercase vowel."); // Display message for uppercase vowel
}
// Check if the symbol is a lowercase vowel
else if ("aeiou".IndexOf(symbol) >= 0) // If the symbol is in the string "aeiou"
{
Console.WriteLine("\nThe symbol is a lowercase vowel."); // Display message for lowercase vowel
}
// Check if the symbol is a digit
else if (Char.IsDigit(symbol)) // If the symbol is a digit
{
Console.WriteLine("\nThe symbol is a digit."); // Display message for digit
}
// If none of the above conditions are true, it's any other symbol
else
{
Console.WriteLine("\nThe symbol is neither a vowel nor a digit."); // Display message for other symbols
}
}
}