Question
I need to write new fucntions from my existing code that is all in main. I also need to prototype them as well??? The three
I need to write new fucntions from my existing code that is all in main. I also need to prototype them as well???
The three fuctions I need are getUserInput, isVowel, and printResult
printResult: void printResult(int vowel, int consonets, int specialCharacters, int numbers);. This should print the same results my code currently outputs.
getUserInput: This function should print the prompt, get the user's input, and return that input. Prototype: string getUserInput();.
isVowel: This function should return true if a given character is a vowel and false otherwise. It shouldn't assume that the character is uppercase/lowercase. Prototype: bool isVowel(char ch);.
Below is my existing code: (C++ code only please)
#include #include using namespace std;
int main() { string s; char ch; int vowels = 0, consonents = 0, specialCharacters = 0, numbers = 0; getline(cin,s); for(int i = 0;i(s.length());i++){ ch = s[i]; if((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')){ if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U'){ vowels += 1; } else{ consonents += 1; } } else if(!(ch>='0' && ch<='9')){ specialCharacters+=1; } else if(ch>='0' && ch<='9'){ numbers += 1; } } cout<<"Vowels: "< cout<<"Consonants: "< cout<<"Digits: "< cout<<"Special characters: "< return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started