/** * Exercise 12.6 p 471 */ public class Exercise126 { // Make all methods public to allow testing /** * a. * modifies names * postcondition * all items in names are assigned the letter 'R' */ public void makeAllRs(char[] names) { if (names==null) return; // just to be safe in all cases for(int i=0; i=2 * modifies * arr[0], arr[1] * postcondition * the values in arr[0] and arr[1] are swapped from their old values */ public void swapFirstTwo(double[] arr) { double temp = arr[0]; arr[0] = arr[1]; arr[1] = temp; } /** * precondition * dArray.length >=1 * postcondition * result is the largest double value of any item in the array */ public double biggestValue(double[] dArray) { double max = dArray[0]; for(int i=1; imax) max = dArray[i]; return max; } /** * precondition * dArray.length >= 1 * postcondition * result is the index of the largest valued item in the array */ public int biggestIndex(double[] dArray) { int maxIndex = 0; for(int i=1; idArray[maxIndex]) maxIndex = i; return maxIndex; } /** * precondition * target.length == source.length * modifies * target * postcondition * the item values in target are reversed in order from source */ public void copyReversed(char[] source, char[] target) { for(int i=0; i