Question: I need to complete the following program so that it computes the sum of all the elements of the array. Can you help me write

I need to complete the following program so that it computes the sum of all the elements of the array. Can you help me write the program so that it works even if the dimensions of the rows and columns are changed. (hardcode it pls)

import java.io.* ; public class ArraySum { public static void main ( String[] args ) { int[][] data = { {3, 2, 5}, {1, 4, 4, 8, 13}, {9, 1, 0, 2}, {0, 2, 6, 3, -1, -8} }; // declare the sum ??? // compute the sum for ( int row=0; row < data.length; row++) { for ( int col=0; col < ???; col++) { ??? } } // write out the sum System.out.println( ); } } 

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!