Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+7 votes
asked in CSC212_Spring2019 by (1 point)

1 Answer

+4 votes

If you are talking about the rowSums method that you need to write for Routine7B, then within the method you should "instantiate" a 1D array (use the new operator.....int[] sums = new int[......]) with the number of elements determined by the number of rows in the 2D array. You don't turn the 2D array into a 1D array, but create a 2nd array that is 1D.

Then, loop through the 2D array accumulating the sum of a row then store that sum into the corresponding element in the 1D array. Sum up row 0 of the 2D array and store the sum as element zero in the 1D array. Sum up row 1 of the 2D array and store the sum as element one in the 1D array, etc. Be sure that each time you begin to sum a new row, the accumulating sum has been reset to zero.

answered by (1 point)
...