Question: A 2 D double array terrainMap is declared and initialized to track the terrain of a city park. Each value in the 2 D array

A 2D double array terrainMap is declared and initialized to track the terrain of a city park. Each value in the 2D array represents the height of a particular latitude and longitude above sea level. Longitude is represented by the columns in the 2D array and latitude is represented by each row in the 2D array.
Which of the following would be the correct way to print out all the indices that are more than 5 feet above sea level?
a
public static void above5(double[][] array){ for(int row =0; row <= array.length; row++){ for(int column =0; column < array[row].length; column++){ if(array[row][column]>5.0){ System.out.println(row +","+ column); }}}}
b
public static void above5(double[][] array){ for(int row = array.length-1; row >0; row--){ for(int column =0; column < array[row].length; column++){ if(array[row][column]>5.0){ System.out.println(row +","+ column); }}}}
c
public static void above5(double[][] array){ for(int row =0; row < array.length; row++){ for(int column =0; column < array[row].length; column++){ if(array[column]>5.0){ System.out.println(row +","+ column); }}}}
d
public static void above5(double[][] array){ for(int row =0; row < array.length; row++){ for(int column =0; column < array[row].length; column++){ if(array[row][column]>5.0){ System.out.println(array[row][column]); }}}}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!