Question: Can someone explain this code with comments I am supposed to dispay an array an add each columns and add each row An application uses

 Can someone explain this code with comments I am supposed to dispay an array an add each columns and add each row An application uses a two-dimensional array declared as follows: int[][] days = new int[29][5]; a. Write code that sums each row in the array and displays the results. b. Write code that sums each column in the array and displays the results. class TwoDimensionalArrayDemo { public static void main( String[] arg ) { int[][] days = new int[29][5]; for (int i = 0; i < days.length; i++) { for (int j = 0; j < days[i].length; j++) { days[i][j] = i + j; } } for (int[] a : days) { for (int i : a) { System.out.print(i + "\t"); } System.out.println(" "); } System.out.println("column totals"); int totalRow = 0; for( int col = 0; col < 5; col++) { totalRow = 0; for( int row = 0; row < 29; row++) totalRow = totalRow + days [row][col]; System.out.println(totalRow); } System.out.println("row totals"); int totalCol; for( int row = 0; row < 29; row++) { totalCol = 0; for( int col = 0; col < 5; col++) totalCol = totalCol + days [row] [col]; System.out.println(totalCol); } } }

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!