Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

java code please 14. Next we\'ll complete the setValues() method. Instead of giv

ID: 3817364 • Letter: J

Question

java code please

14. Next we'll complete the setValues() method. Instead of giving you exact code I'll tell you what to do. Use other code as a guide.
Start with a for loop with a start of int i = 0
Set the ending point of when i is less than the length of the arr array.
Set the incrementation to increase i by 1 using the unary operator ++.
Within the loop set the arr array element with an index of i to equal the variable value.
Call the animate() method with an argument of i like we did in the sortArray() method.


15. Next you're to complete the countFrequency() method. As with the previous method I'll tell you what you need to do without actually giving you the code.
create an integer named count and set its value to zero.
Using a for loop with a starting value of zero, an ending value of when the loop's variable is less than the length of the array, and increment by one. Within the loop:
create an if statement with an argument that checks to see if the variable value equals the current element of the array. The variable value is part of the method's parameters. If the condition is true increase the variable count by 1 and call the animate() method passing the value of the loop's variable AND the value of count. This is the second animate() method in the class.
After the loop change the return statement so that it returns count rather than returning zero.

16. Next you'll complete the findMinimum() method.
Within the method create an integer named minimum and set it to equal the first element in the array. Remember that index numbers start with zero.
Create a for loop with a starting point of zero, an ending point of when the variable is less than the length of the array, and increments by one. Within the loop:
create an if statement with an argument that checks to see if the variable minimum is greater than the element in the array with an index number of the loop's variable, e.g. minimum > arr[i]
Within the if statement change the value of the variable minimum to equal the current element in the array, and like the previous method, call the animate() method passing to it the value of the loop's variable and the value of the variable minimum.
After the loop change the return statement so it returns the variable minimum rather than returning zero.

Explanation / Answer

16.

public int findMinimum(){

int minimum=arr[0];

for(int i=0;i<arr.length;i++){

if(minimum>arr[i]){

minimum=arr[i];

animate(i,minimum);

}

}

return minimum;

}