Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started