Reference no: EM132200921
Question :
Write a Java program that asks the users to enter a m × n matrix of integers, m and n being the number of rows and columns, respectively.
The program stores this matrix into a two-dimensional m × n array.
Then, write a class with the following three methods:
- Method 1 accepts the m × n array as its argument, performs its transpose, and returns the transposed n × m array;
- Method 2 accepts the jth column of the array as its argument, and returns the maximum of the column elements;
- Method 3 accepts the ith row of the array as its argument, and returns the average of the row elements.
Use this class in the main program to find the transpose, the maximum of column elements, and the average of row elements. The program should display all three results as shown below.
For example, if the user enters the following content:
20 -5 90 22 32
34 29 -3 44 2
100 0 92 37 0
The program should output:
The transpose is: 20 34 100
-5 29 0
90 -3 92
22 44 37
32 2 0
The maximum of all the column elements:
100 29 92 44 32
The average of all the row elements:
31.8
21.2
45.8