Question

java code please 14. Next we'll complete the setValues() method. Instead of giving you exact code...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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;

}

Add a comment
Know the answer?
Add Answer to:
java code please 14. Next we'll complete the setValues() method. Instead of giving you exact code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Anybody Know how to Solve this Problem Thank you very much // ***** 1. This method...

    Anybody Know how to Solve this Problem Thank you very much // ***** 1. This method has been coded as an example /** Fills the array with random numbers between 50 and 80 * The instance variable named intArray is the integer array to be * filled with values */ public void fillValues( ) { Random rand = new Random( ); for ( int row = 0; row < intArray.length; row++ ) { System.out.print( row + "\t" ); for (...

  • How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++...

    How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...

  • Step 1. Start Netbeans and create a project called ArrayLab Step 2. Write the main method...

    Step 1. Start Netbeans and create a project called ArrayLab Step 2. Write the main method  Declare and initialize an array called myNums int myNums = {3, 8, 12, 4, 2, 9, 6};  Declare an int called largestNum and set it to 0.  Write a for loop that prints the array for (int index = 0; index < myNums.length; index++) { System.out.println(myNums[index] + “ “); }  Write a for loop that prints the array backwards ...

  • Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory...

    Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int * ) named ptr_1. Use ptr_1 to assign the number 7 to that dynamically allocated integer, and in another line use printf to output the contents of that dynamically allocated integer variable. Write the code to dynamically allocate an integer array of length 5 using calloc or malloc and have it pointed...

  • Our 1st new array operation/method is remove. Implement as follows: public static boolean remove( int[] arr,...

    Our 1st new array operation/method is remove. Implement as follows: public static boolean remove( int[] arr, int count, int key ) { 1: find the index of the first occurance of key. By first occurance we mean lowest index that contains this value. hint: copy the indexOf() method from Lab#3 into the bottom of this project file and call it from inside this remove method. The you will have the index of the value to remove from the array 2:...

  • Using C programming

    Using C, create a data file with the first number being an integer. The value of that integer will be the number of further integers which follow it in the file. Write the code to read the first number into the integer variable how_many.Please help me with the file :((This comes from this question:Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int...

  • Create a Java code that includes all the methods from the Lecture slides following the ADTs...

    Create a Java code that includes all the methods from the Lecture slides following the ADTs LECTURE SLIDE Collect/finish the Java code (interface and the complete working classes) from lecture slides for the following ADTS 2) ArrayList ADT that uses a linked list internally (call it LArrayList) Make sure you keep the same method names as in the slides (automatic testing will be performed)! For each method you develop, add comments and estimate the big-O running time of its algorithm....

  • . In the method main, prompt the user for a non-negative integer and store it in...

    . In the method main, prompt the user for a non-negative integer and store it in an int variable num (Data validation is not required for the lab). Create an int array whose size equals num+10. Initialize the array with random integers between 0 and 50 (including 0 and excluding 50). Hint: See Topic 4 Decision Structures and File IO slides page 42 for how to generate a random integer between 0 (inclusive) and bound (exclusive) by using bound in...

  • please do everything in matlab with commets next to each line of code thank you! %%...

    please do everything in matlab with commets next to each line of code thank you! %% Problem 1 - 1 point % Create a 100-element array, A, which is a random array of integers % Use the randi function for this, 'help randi' %% Problem 2 - 1 point % Use a 'for' loop and an 'if' statement to count how many odd numbers there are in the % array you made in #1 above %% Problem 3 - 1...

  • I am working on my java but I keep getting this one wrong. Method Name: arrayContains...

    I am working on my java but I keep getting this one wrong. Method Name: arrayContains Access modifier: Private Parameters: 1 integer named number Return type: boolean Purpose: This method returns a true or a false indicating if the number is present in an array or not. In order for this method to work, there must be an array already declared. Therefore, in the CLASS BLOCK, declare an array as follows: static int[] listof Numbers = {1, 2, 3, 4,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT