CS 112 In-Class Assignment
Final Review I
Get ready for the Final:
- Create a class ArrayManipulate. This class should have no
instance variables, but the following methods
- int largestClump(Object data[]). Returns the largest number of
adjacent identical elements in the array. So, for the array
[1,3,5,4,4,3,2,5,5,5,1], your method should return 3 (since there is
a "clump" of 3 5's. Your method needs to work for any array of
objects.
- int range(int data[]). Returns the range of elements in the
array. So, for the array [3, 4, 1, 7, 8, 2, 6], your method should
return 8 (since there are 8 values between 1 and 8)
- void makeAbs(int data[]). Replaces every element data with its
absoulte value.
- int mode(int data[]). Return the element that occurs the most
often in the list. So, for the array [3, 2, 1, 4, 6, 4, 2, 6, 4, 7,
5], the method should return 3. This one is a bit trickier
- Create a main driver method (either within ArrayManipulate, or
in a different class) that creates an instance of
ArrayManipulate, creates some test arrays, and then test the
methods. The methods Arrays.toString and Arrays.deepToString may
help in debugging
Soluion:
ArrayManipulate.java