Question: this assignment need to be done in java only Requirements: Ask the user to enter the size of an array (int value) Allocate a 2D

this assignment need to be done in java only

Requirements:

  • Ask the user to enter the size of an array (int value)
  • Allocate a 2D array of int that size (if the user enters in 5, then allocate a 5x5 array)
  • Using a Random, initialize each element of the array to be either 0 or 1
  • Output the array in a table format (see below for an example)
  • Output the fraction of your array that is ones and the fraction that is zeros. For example, suppose the user asked for a 3x3 array and after initialization that array happened to contain 4 ones and 5 zeros. The fraction of ones would be 4/9 and the fraction of zeros would be 5/9.
  • Calculate and output the sum of each row. Output the index of the largest row sum.
  • Calculate and output the sum of each column. Output the index of the largest column sum.
  • Out rows win if the largest row sum is greater than the largest column sum. Otherwise, output columns win
  • Calculate the diagonal sum. Use the diagonal starting at location [0][0] and going down to [N-1][N-1] for an array of size N.
  • Output diagonals rule if the diagonal sum is greater or equal to the largest row sum and greater than or equal to the largest column sum.
  • Below are three example runs.

please comments on the code so i can understand

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!