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?
public static void above5(double[][] array)
A)
{
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);
}
}
}
}
B)
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);
}
}
}
}
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[row][column] > 5.0)
{
System.out.println(array[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[column] > 5.0)
{
System.out.println(row +"," + column);
}
}
}
}