Menu

[Solved]Java 1 Given Linearsearch Method Alter Takes Arraylist Doubles Parameter Rather Array Doub Q37301061

JAVA

1. Given the below linearSearch method, alter it so that ittakes in an ArrayList of doubles as a parameter rather than anarray of doubles:

public static int linearSearch(double[] array, int currentSize,double value) {

    for (int i = 0; i < currentSize; i++){

        if (array[i] ==value) {

           return i;

        }

    }

    return -1;

}

2. Declare a 2D array of doubles of dimension 2 X 3 namedcentimeters and assign it the values {2.5, 3.5, 4.5} and {5.5, 6.5,7.5} in 3 ways!

3. Then, write a nested for loop to print the above array to theconsole.

Expert Answer


Answer to JAVA 1. Given the below linearSearch method, alter it so that it takes in an ArrayList of doubles as a parameter rather … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *