im new to the forum and this is my first class in computer science and need a counter for this program so when the user finally says no to continueing the program adds up all the vowels that were inputted.
// ====================
using namespace std;
// ====================
// =============
int main( ) {
char M;
bool validAnswer;
char userAnswer;
int counter;
counter = 0;
do {
cout << "Enter a letter and i will tell you if it is a vowel." << endl;
cin >> M;
if ( M == 'A' || M == 'a'|| M == 'E' || M == 'e' || M == 'I' || M == 'i' ||
M == 'O' || M == 'o' || M == 'U' || M == 'u') {
cout << "Letter is a vowel. " << endl;
counter++;
}
else {
cout << "Letter is not a vowel. " << endl;
}
do {
cout << " user do you wish to continue?" << endl;
cin >> userAnswer;
if ((userAnswer == 'y') || (userAnswer == 'Y' ) ||(userAnswer =='n')|| (userAnswer == 'N'))
validAnswer = true;
else {
validAnswer = false;
cout << "Invalid answer: choose y, Y, n, N" << endl;
}
} while (!validAnswer);
} while ((userAnswer =='y') || (userAnswer == 'Y'));