Question: JAVA Find the Row With the Max Sum in a Matrix: Overview: Find the sum of every row in a 2 dimensional Array. Determine which

JAVA Find the Row With the Max Sum in a Matrix:

Overview: Find the sum of every row in a 2 dimensional Array. Determine which row has the max sum. If there is a tie, the row closer to the bottom of the matrix wins.

Setup:

Create a class (.java) file called MaxRow.java

(This can be within a project that contains the other parts of this homework or it can be in separate project on its own)

Features:

generate a 3 x 3 matrix (that is a 3-element Array consisting of Arrays with 3 elements), with each value in the matrix being a random number from 0 - 9

print it out

determine which row has the largest sum

if two rows have the same sum, the row closest to the bottom should be considered the largest

print out both the row number (can simply be index 0, 1 or 2) and the sum

write at least two methods with javadoc formatted comments to do this

Example Output:

(Prints out sum and index of row with max sum.)

4 9 0

8 3 8

1 0 1

Row 1 has the largest sum: 19

(If two rows have same sum, use index of closest to bottom.)

6 1 5

2 5 0

0 4 9

Row 2 has the largest sum: 13

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!