Question: Write a method named filterOnMax that takes a Queue of Integers and an integer value named max as parameters and returns a new Queue of
Write a method named filterOnMax that takes a Queue of Integers and an integer value named max as parameters and returns a new Queue of Integers that contains only the values in the original queue that are less than or equal to the value of max. The new Queue should preserve the order of the old Queue, and the old Queue should be empty when this method is finished. There is no guarantee that the values in the input Queue will be sorted. Your method should display an understanding of FIFO Queue processing so make sure your code uses only Queue operations on the Queue objects (add, remove, and peek). Your method should use the following header:
public static QueuefilterOnMax(Queue input, int max)
Write a method named filterOutVowels that takes a Stack of Characters and returns a new Stack of Characters that contains only the values in the original Stack that are not vowels ('a','e','i','o','u'). When the method is complete, the original Stack should be empty. The new Stack must have its elements in the same order as the original Stack, so you will need to do something to preserve the order of the original Stack as you are making your choices (hint - you will want to use a third Stack beyond just the input and output Stacks). Your code should work for capital or lowercase letters (so you may want to use the methods Character.toUpperCase or Character.toLowerCase in your code). Your method should display an understanding of Stack processing, so make sure your code uses only Stack operations on your Stack objects (push, pop and peek). Your method should use the following header:
public static StackfilterOutVowels(Stack input)
Without enterint it into eclipse, trace the following piece of code. After the segment is finished running, what will the contents of the Set mySet be?
SetmySet = new HashSet (); mySet.add('a'); mySet.add('b'); mySet.add('a'); mySet.add('c'); mySet.add('c'); mySet.add('d'); mySet.remove('a');
Think back to your knowledge of mathematical Set operations. The union of two Sets A and B is everything that is in Set A along with everything that is in Set B with no duplicates. For example, if Set A contained {'A','C','D'} and Set B contained {'A','B','C'} then the union of A and B would contain {'A','B','C','D'}. Write a method named union that takes two Sets of Integers as parameters A and B and returns a new Set of Integers that contains the union of A and B. The original Sets A and B should be the same after the method is finished as they were when the method started.
Continuing on from problem 5, the intersection of two Sets A and B is everything that is in both of the Sets A and B. For example if Set A contained {'A','C','D'} and Set B contained {'A','B','C'} then the intersection of A and B would contain {'A','C'}. Write a method named intersection that takes two Sets of Integers as parameters A and B and returns a new Set of Integers that contains the intersection of A and B. The original Sets A and B should be the same after the method is finished as they were when the method started.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
