Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Two-dimensional Arrays The following code fragment is intended to sum the totals

ID: 3739216 • Letter: T

Question

Two-dimensional Arrays The following code fragment is intended to sum the totals of the items in each row of two-dimensional array items, and displays each row’s total. Correct the errors in the code that will result in either an incorrect answer being printed or compile-time error, and write the program that runs without these errors.

for (int row = 0; row < items.length; row++) {

int total = 0;

for (int column = 0; column < items[column].length; column++)

total += item s[row][column];

System.out.printf("Row %d's total is %d%n", row, total); }

Explanation / Answer

for (int row = 0; row