ata structure & Algorithum Write code that accomplishes the following tasks: Consider two bags that can hold strings. One bag is name letters and contain several one-letter strings. The other bag is empty and is named vowels. One at a time, remove a string from letters. If the strings contain a vowel, place it into the bag vowels; otherwise, discard the string. After you have checked all of the strings in letters, report the number of vowels in the bag vowels and the number of times each vowel appears in the bag.
Data structure & Algorithum
Write code that accomplishes the following tasks: Consider two bags that can hold strings. One bag is name letters and contain several one-letter strings. The other bag is empty and is named vowels. One at a time, remove a string from letters. If the strings contain a vowel, place it into the bag vowels; otherwise, discard the string. After you have checked all of the strings in letters, report the number of vowels in the bag vowels and the number of times each vowel appears in the bag.
1. Declare and initialize Bag object named letters.
2. Add several one-letter strings to letter object
3. Declare and initialize another Bag object vowels.
4. Removed a atring from the letters object
5. If the removed string is a vowel, add that vowel to the vowel Bag object.
6. Repeat removed and vowel check for entire Bag.
7. Display the number of vowels in the Bag.
8. Display the frequency of occurrences each vowel appears.
Step by step
Solved in 2 steps with 2 images