Vowel - switch Learn programming C#



Lesson:

Basic Data Types


Exercise:

Vowel - switch


Objetive:

Create 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".


Code:

using System;
public class exercise60
{
    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;
        }
    }
}



Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.