1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#include<iostream>
using namespace std;
int main()
{
char sentence=' ';
int count=0,count1=0,count2=0,count3=0,count4=0;
cout<<"Enter a sentence: ";
cin.get(sentence);
// cout<<"Vowels: ";
while (sentence!='\n')
{
// Test
cout << sentence <<" There are "<<count<<" a's, "<<count1<<" e's, "
<<count2<<" i's, "<<count3<<" o's, and "<<count4<<" u's in the sentence." << endl;
cin.get(sentence);
switch(sentence)
{
case 'A':;
count++;
break;
case 'a':;
count++;
case 'E':;
count1++;
break;
case 'e':;
count1++;
break;
case 'I':;
count2++;
break;
case 'i':;
count2++;
break;
case 'O':;
count3++;
break;
case 'o':;
count3++;
break;
case 'U':;
count4++;
break;
case 'u':;
count4++;
break;
}
// Test
cout << sentence <<" There are "<<count<<" a's, "<<count1<<" e's, "
<<count2<<" i's, "<<count3<<" o's, and "<<count4<<" u's in the sentence." << endl<< endl;
}
cout<<"There are "<<count<<" a's, "<<count1<<" e's, "
<<count2<<" i's, "<<count3<<" o's, and "<<count4<<" u's in the sentence.";
return 0;
}
|