?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

2-Dimensional Array of Heights

APCSA-T1LVDE

Consider the following code segment.

int[][] heights = new int[3][6];
heights[0][0] = 10; 
heights[1][0] = 20; 
heights[2][0] = 30;
double total = 0;
int count = 0;
for (int r=0; r<heights.length; r++)
{    
    for (int c=0; c<heights[r].length; c++)
    {
        total += heights[r][c];
        count++;
    }
}
System.out.println(total/count + ", " + total/heights.length + ", " +  total/heights[0].length);

Which of the following is approximately the output printed to the console after this segment of code is executed?

A

20.0, 20.0, 10.0

B

3.3, 3.3, 3.3

C

20.0, 20.0, 20.0

D

10.0, 10.0, 10.0

E

3.3, 20.0, 10.0