Q:

Write a program named CountVowels that accepts a phrase from the user and counts the number of vowels in the phrase. For this exercise, count both uppercase and lowercase vowels, but do not consider y to be a vowel

0

Write a program named CountVowels that accepts a phrase from the user and counts the number of vowels in the phrase. For this exercise, count both uppercase and lowercase vowels, but do not consider y to be a vowel.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace _13_CountVowels
{
    class CountVowels
    {
        static void Main(string[] args)
        {
            WriteLine("CountVowels");

            string in_phrase = "";
            int vowelCount = 0;
            char checkLetter = '\0';

            Write("Enter Phrase: ");
            in_phrase = ReadLine();

            for (int i = 0; i < in_phrase.Length; ++i)
            {
                checkLetter = char.ToUpper(in_phrase[i]);
                switch(checkLetter)
                {
                    case 'A':
                    case 'E':
                    case 'I':
                    case 'O':
                    case 'U':
                        vowelCount++;
                        break;
                }
            }
            WriteLine("Vowels :" + vowelCount);

            WriteLine("--End--");
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now