enter the size of the array... 10100 11011 00101 11100 00101 fraction of ones = 13/25 fraction of zeros = 12/25 row 0 sum = 2 row 1 sum = 4 row 2 sum = 2 row 3 sum = 3 row 4 sum = 2 row 1 has the largest row sum! col 0 sum = 3 col 1 sum = 2 col 2 sum = 4 col 3 sum = 1 col 4 sum = 3 col 2 has the largest col sum! columns win! diagonal sum is 4 diagonals rule
How to write a program in java that ask the user to input an int size value into a 2d array, then output a table of random 0 and 1 of that size (table must be a perfect square), then output the fraction of your array that is ones and the fraction that is zeros, then output the sum for each row, the sum of colunms and which row and colunm have the largest sum, then determine if the largest row sum is greater than the largest column sum or vice versa, then output the sum of the diagonal(the diagonal starting at location [0][0] and going down to [N-1][N-1] for an array of size N) and determine if the diagonal sum is greater or equal to the largest row sum and greater than or equal to the largest column sum?
output should look similar to screen shot
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 4 images