Reference no: EM132200849
Write a JAVA program which does the following:
Give the user a menu choice
Option 1: Randomly Generate a 2D array. This option will ask the user for the number of rows and columns in the array, as well as the range of numbers to generate, (i.e. The user can choose the min and max of the random number formula.) The random numbers should be integers.
Option 2: Populate an array using File I/O. This option will ask the user to enter the name of a file OR use JFileChooser to read data from an input file. The file will have the following format: The first two numbers will be the dimensions of the array (rows and columns). The rest of the numbers will be the data for the array.
Once the array has been created using one of the above two options. Display the following results:
Display the array in table format. (Print the 2D array)
Calculate and display the sum and average of the entire array.
Calculate and display the sum and average of each row.
Calculate and display the sum and average of each column.
Calculate and display the sum and average of the major and minor diagonals *see below.
Display the row and col with the highest average.
Display the row and col with the lowest average.
Be sure to use appropriate methods or the program will be worth no credit.
Major Diagonal: runs from upper Minor Diagonal: runs from upper right
left to lower right to lower left
1 2 3 1 2 3 1 2 1 2 3 1 2 3 1 2
3 4 5 4 5 6 3 4 3 4 5 4 5 6 3 4
7 8 9 5 6 7 8 9 5 6