//************************************** // Name: Count Vowel, Consonants, Digits and Whitespace in C++ // Description:In this program will ask the user to give a sentence and then the program using switch statement will count the vowels, consonants, digits and white space using C++. I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work, computer tutorials and web development work kindly contact me in the following email address for further details. If you want to advertise in my website kindly contact me also in my email address also. Thank you. My email address are the following jakerpomperada@gmail.com, jakerpomperada@aol.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360. My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675. My personal website is http://www.jakerpomperada.com // By: Jake R. Pomperada // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //************************************** #include <iostream> #include <string> using namespace std; main() { string sentence; int NumChars=0, VowelCount=0, ConsonantCount=0; int whitespace=0, digits=0; cout << "Enter a String :=> "; getline(cin,sentence); NumChars = sentence.length(); for (int i=0; i < NumChars; i++) { switch(sentence.at(i)) { case 'a' : case 'A' : case 'e' : case 'E' : case 'i' : case 'I' : case 'o' : case 'O' : case 'u' : case 'U' : VowelCount++; break; case 'b' : case 'B' : case 'c' : case 'C' : case 'd' : case 'D' : case 'f' : case 'F' : case 'g' : case 'G' : case 'h' : case 'H' : case 'j' : case 'J' : case 'k' : case 'K' : case 'l' : case 'L' : case 'm' : case 'M' : case 'n' : case 'N' : case 'p' : case 'P' : case 'q' : case 'Q' : case 'r' : case 'R' : case 's' : case 'S' : case 't' : case 'T' : case 'w' : case 'W' : case 'x' : case 'X' : case 'y' : case 'Y' : case 'z' : case 'Z' : ConsonantCount++; break; case ' ' : whitespace++; break; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : case '0' : digits++; } } cout << "\n\n"; cout << " \n === SUMMARY OF REPORTS ===== "; cout << "\n\n"; cout << "\nNumber of Vowels :=> " << VowelCount << "."; cout << "\nNumber of Consonants :=> " << ConsonantCount << "."; cout << "\nNumber of Digits :=> " << digits << "."; cout << "\nNumber of WhiteSpce :=> " << whitespace << "."; cout << "\n\n"; system("PAUSE"); }