Answer to Question #174151 in C++ for Boopathi

Question #174151

Design the class Vowel to find the number of vowels present in the given string. Define the constructor member function to assign the values and destructor member function to destroy the data objects.


1
Expert's answer
2021-03-25T18:21:47-0400
class Vowel
{
public:
    Vowel(string str) : s(str) {}
    
    ~Vowel() {}
    
    int Count()
    {
        int vowels = 0;
        for (int i = 0; i < s.length(); ++i)
        {
            switch (s[i])
            {
                case 'a':
                case 'e':
                case 'i':
                case 'o':
                case 'u':
                case 'y':
                    ++vowels;
                    break;
            }
        }
        return vowels;
    }
    
private:
    string s;
}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS