Question #48965

How to write a program to check whether the input alphabet is a vowel or not using switch case in c#.

Expert's answer

Answer on Question #48965 – Engineering – Other

Task

How to write a program to check whether the input alphabet is a vowel or not using switch case.

Solution (C#)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threadings Tasks;
namespace IsVowel2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a string");
// enter string
string enter = Console.ReadLine();
// convert string symbols to low case
enter = enter.ToLower();
int[] counter = new int[6]
// check string chars
for (int i=0; i<enter.length; i="" i++)="" switch="" {=""> {
switch (enter[i])
{
case 'a': counter[0]++;
break;
case 'e': counter[1]++;
break;
case 'i': counter[2]++;
break;
case 'o': counter[3]++;
break;
case 'u': counter[4]++;
break;
case 'y': counter[5]++;
break;
}
}
// printing results
Console.WriteLine("The statistic of vowels in the string is:");
Console.WriteLine("a - {0}\t e - {1}\t i - {2}\t o - {3}\t u - {4}\t, y - {5}\n",
counter[0], counter[1], counter[2], counter[3], counter[4], counter[5]);
Console.ReadKey();
}
}
}


http://www.AssignmentExpert.com/</enter.length;>


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS