Question: I'm having trouble writing methods for problem set E7.10 (a-j) Practice Exercises 363 that adds a value, provided there is still room. Provide methods to

I'm having trouble writing methods for problem set E7.10 (a-j)

I'm having trouble writing methods for problem set E7.10 (a-j) Practice Exercises

Practice Exercises 363 that adds a value, provided there is still room. Provide methods to compute the sum, average, maximum, and minimum value. E7.10 Write array methods that carry out the following tasks for an array of integers by completing the Arrayblethods class below. For each method, provide a test program. public class ArrayMethods private int[] values; public ArrayMethods (int[] initialValues) values initialValues; ) public void swapFirstAndLastO[..- public void shiftRightO . . . 1 a. Swap the first and last elements in the array. b. Shift all elements to the right by one and move the last element into the first position. For example, 149 1625 would be transformed into 25 14916. c. Replace all even elements with 0. d. Replace each element except the first and last by the larger of its two neighbors. e. Remove the middle element if the array length is odd, or the middle two elements if the length is even. f. Move all even elements to the front, otherwise preserving the order of the elements. 9 Return the second-largest element in the array h. Return true if the array is currently sorted in increasing order. i. Return true if the array contains two adjacent duplicate elements. j. Return true if the array contains duplicate elements (which need not be adjacent). E7.11 Consider the following class: public class Sequence private int values; public Sequence (int size) valuesne int[size]; public void set (int i, int n) valuesi] n; public int get(int i) return values[i];h public int sizeO return values.length; Add a method public boolean equals(Sequence other) that checks whether two sequences have the same values in the same order E7.12 Add a method public boolean sameValues (Sequence other) to the Sequence class of Exercise E7.11 that checks whether two sequences have the same values in some order, ignoring duplicates. For example, the two sequences 1 4 9 16 97 4 9 11 and 11 11 79 16 4 1 would be considered identical. You will probably need one or more helper methods. Practice Exercises 363 that adds a value, provided there is still room. Provide methods to compute the sum, average, maximum, and minimum value. E7.10 Write array methods that carry out the following tasks for an array of integers by completing the Arrayblethods class below. For each method, provide a test program. public class ArrayMethods private int[] values; public ArrayMethods (int[] initialValues) values initialValues; ) public void swapFirstAndLastO[..- public void shiftRightO . . . 1 a. Swap the first and last elements in the array. b. Shift all elements to the right by one and move the last element into the first position. For example, 149 1625 would be transformed into 25 14916. c. Replace all even elements with 0. d. Replace each element except the first and last by the larger of its two neighbors. e. Remove the middle element if the array length is odd, or the middle two elements if the length is even. f. Move all even elements to the front, otherwise preserving the order of the elements. 9 Return the second-largest element in the array h. Return true if the array is currently sorted in increasing order. i. Return true if the array contains two adjacent duplicate elements. j. Return true if the array contains duplicate elements (which need not be adjacent). E7.11 Consider the following class: public class Sequence private int values; public Sequence (int size) valuesne int[size]; public void set (int i, int n) valuesi] n; public int get(int i) return values[i];h public int sizeO return values.length; Add a method public boolean equals(Sequence other) that checks whether two sequences have the same values in the same order E7.12 Add a method public boolean sameValues (Sequence other) to the Sequence class of Exercise E7.11 that checks whether two sequences have the same values in some order, ignoring duplicates. For example, the two sequences 1 4 9 16 97 4 9 11 and 11 11 79 16 4 1 would be considered identical. You will probably need one or more helper methods

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!