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
Get step-by-step solutions from verified subject matter experts
