Question: JAVA HW Assignment. To the HighArray class in the highArray.java program, add the following methods: A) getMax() that returns the value of the highest key
JAVA HW Assignment.
To the HighArray class in the highArray.java program, add the following methods:
A) getMax() that returns the value of the highest key (value) in the array without removing it from the array, or 1 if the array is empty.
B) removeMax() that removes the item with the highest key from the array.
C) reverse() method for the HighArray class to reverse the order of elements of the array.
Add code necessary in main() to exercise these methods.
Sample output of Current HighArray class:
77 99 44 55 22 88 11 0 66 33
Can't find 35
77 44 22 88 11 66 33
Sample output of HighArray class once you do the above methods:
current array items: 77 99 44 55 22 88 11 0 66 33
Can't find 35
array items after delete some values: 77 44 22 88 11 66 33
the Max is 88
the array after calling max method: 77 44 22 88 11 66 33
the array after calling remove max method: 77 44 22 11 66 33
the new max is 77
the array after calling reverse method 33 66 11 22 44 77
JAVA // highArray.java // demonstrates array class with high-level interface // to run this program: C>java HighArrayApp //////////////////////////////////////////////////////////////// class HighArray { private long[] a; // ref to array a private int nElems; // number of data items //----------------------------------------------------------- public HighArray(int max) // constructor { a = new long[max]; // create the array nElems = 0; // no items yet } //----------------------------------------------------------- public boolean find(long searchKey) { // find specified value int j; for(j=0; j Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
