Question: Write an application that uses two-dimensional arrays, parallel one-dimensional arrays, and ArrayLists to find the largest rows and columns. Your application will randomly fill an
Write an application that uses two-dimensional arrays, parallel one-dimensional arrays, and ArrayLists to find the largest rows and columns. Your application will randomly fill an n x n matrix with 0s and 1s. Then, using two one-dimensional ararys and two ArrayLists (one of each for rows, one of each for columns), count the number of 1s. Lastly, output the row and column numbers with the most 1s.
Rules You must get the value of n from the user.
You must store the counts of the number of 1s (or sums) for the rows and columns in one-dimensional arrays that are parallel to the two-dimensional array
You must use ArrayLists to keep track of the rows and columns with the most 1s
Task Write an application that uses two-dimensional arrays, parallel one-dimensional arrays, and ArrayLists to find the largest rows and columns. Your application will randomly fil an nxn matrix with Os and 1s. Then, using two one-dimensional ararys and two ArrayLists (one of each for rows, one of each for columns), count the number of 1s. Lastly, output the row and column numbers with the most 1s. Rules . You must get the value of n from the user. . You must store the counts of the number of 1s (or sums) for the rows and columns in one-dimensional arrays that are parallel to the two-dimensional array You must use ArrayLists to keep track of the rows and columns with the most 1s Here are a few sample runs (user input in bold): Sample 1 Enter the array size: 42 1 1 1 1 1010 0001 0000 The largest row is: [0] The largest column is: [0, 2, 3] Sample 2 Enter the array size: 72 0110101 1100101 0000100 0000101 1010000 0000111 0001000 The largest row is: [0, 1] The largest column is: [4]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
