COP 3337 Section U05 Spring 2017 HOMEWORK #5 Due: April 19, 2017 Do the problem that is next to your name. Do not use the classes Arrays, Collections, Set, or Map. You can use the java.lang.reflect.Array class. Use equals to test if two items are equal. Problem A. ---------- Write the class Generics that contains the following static generic methods: public static > void sort(T[] arr) public static T[] commonItems( T[] arr1, T[] arr2) public static > T[] scaleDown(T[] arr, T max) public static T[] doubleTheArray(T[] arr) The first method sorts the array arr in the increasing order of compareTo. Use any sorting method that you like. The second method returns an array that contains the items that occur in both array1 and array2. Assume that the 2 arrays have no duplicate items. For example, if arr1 = {"Alex", "Tom", "Bill"} and arr2 = {"Mary", "Tom", "Susan", "Bill'} the method returns the array {"Tom", "Bill"} If one or both arrays are null, the output is the null array. If the 2 arrays have no atoms in common, commonItems returns the empty array. The third method returns an array that contains all items of arr that are <= max. For example, if T = String, arr = { "Alex", "Bill", "Zoila", "Markey", "Shrek", "Tornado", "Zorba"}, and val = "Shrek", the method returns { "Alex", "Bill", "Markey", "Shrek"}. The last method returns an array that doubles the size of the input array and copies its contents at the beginning of the output array. Obey the style rules from the preceding homeworks. Problem B. ---------- Write the class Generics that contains the following static generic methods: public static > boolean isSorted(T[] arr) public static boolean lessThanOrEqualTo(T[] arr1, T[] arr2) public static int repeatedItems(T[] arr) public static boolean hasDuplications(T[] arr) The method isSorted(T[] arr) returns true if arr is sorted in increasing order and false if it is not. The null array and the arrays with 0 or 1 item are assumed to be sorted. The method lessThanOrEqualTo(T[] arr1, T[] arr2) returns true if every item of arr1 occurs in array2. If arr1 == null or arr1.length == 0, return true. For example lessThanOrEqualTo({ "Bill", "Mark", "Bill", "Mark", "Bill"}, {"Bill", "Alex", "Mark"}) returns true because every item of arr1 is in arr2. The third method returns the number of items in arr that occur more than once in the array. For example, repeatedItems( {"Bill", "Susan", "Bill", "Mark", "Bill", "Mark"}) returns 2 because "Bill" and "Mark" occur more than once. The last method returns true if arr contains an item that occurs in arr more than once and returns false if every item occurs only once. Obey the style rules from the preceding homeworks. Below is the problem assignment: 1. Ariel Antunez A 2. Rolans Apinis B 3. Richard Avenarius A 4. David Barahona A 5. Oscar Barbosa B 6. Jose Beliz Crespo B 7. Yahn Bonet A 8. David Castaneda B 9. Maria Correa B 10. Gabriela Curbelo A 11. Jacob Ehrlich B 12. Raul Espinosa A 13. David Giles B 14. Alexander Gomez A 15. Brian Huici A 16 . Keegan Lee B 17. Ernesto Leon A 18. Arian Lopez B 19. Joseph Marrero B 20. Roel Marten A 21. Eddy Mogollon A 22. Cesar Nolasco Jr A 23. Austin Nowak B 24. Daniel Perez B 25. Michael Romero A 26. Kenny Roy A 27. Ramon Sanchez B 28. Isaac Smith B