Please need some help with this question please also explain
Please need some help with this question please also explain what you did
ALSO PLEASE DO NOT USE toArray() method and ArrayList object
Write statements from the client perspective to accomplish the following task.
You are given two BagInterface objects called letters and vowels.
letters contains one-letter strings.
vowels is initially empty.
Remove the Strings from letters.
If the String is a vowel, place it in the vowels bag.
Otherwise, discard the String.
Once the letters bag is empty, print out the number of vowels that are in the vowels bag and the number of times each vowel appears in the bag.
Notes:
You can use a second, initially empty BagInterface object, called tempBag, if it helps.
For full credit, do not use the toArray() method.
For example, if letters initially contained
a, f, v, q, e, a, o, g, y, h, e, q, u
Then after your code completes, letters will be empty and vowels will contain:
a, e, a, o, e, u
And your program will output something like this:
There are 6 vowels in the bag:
a- 2
e- 2
i- 0
o- 1
u- 1
Solution
Ans)
#include<stdio.h>
int main()
{
char letters[100];
int i;
int vowels=0,count1=0,count2=0,count3=0,count4=0,count5=0;
printf(\"enter a line of string :\");
scanf(\"%s\",letters);
for(i=0;letters[i]!=\'\\0\';++i)
{
if(letters[i]==\'a\' || letters[i]==\'A\' || letters[i]==\'e\' || letters[i]==\'E\' || letters[i]==\'i\' || letters[i]==\'I\' || letters[i]==\'o\' || letters[i]==\'O\' || letters[i]==\'u\' || letters[i]==\'U\')
{
++vowels;
}
else if( (letters[i]>=\'a\' && letters[i]<=\'z\') || (letters[i]>=\'A\' && letters[i]<=\'Z\') )
{
continue;
}
}
for(i=0;letters[i]!=\'\\0\';++i)
{
if(letters[i]==\'a\' || letters[i]==\'A\')
{
count1++;
}
else if(letters[i]==\'e\' || letters[i]==\'E\')
count2++;
else if(letters[i]==\'i\' || letters[i]==\'I\')
count3++;
else if(letters[i]==\'o\' || letters[i]==\'O\')
count4++;
else if(letters[i]==\'u\' || letters[i]==\'U\')
count5++;
}
printf(\"There are %d vowels\ \",vowels);
printf(\"a - %d \ \",count1);
printf(\"e - %d\ \",count2);
printf(\"i - %d\ \",count3);
printf(\"o - %d\ \",count4);
printf(\"u - %d\ \",count5);
}



