Question: please indent the code for better understanding and also please compile the results shown with a screenshot. please use basic java language for freshmen In

please indent the code for better understanding and also please compile theresults shown with a screenshot. please use basic java language for freshmenplease indent the code for better understanding and also please compile the results shown with a screenshot. please use basic java language for freshmen

In this problem, we will code up four functions that can be applied to 2-dimensional arrays (or matrices in mathematical term). Given the following 2-D array of double type, {{4.3, 2.7, 8.5, 3.2, 9.8}, {7.4, 5.6, 3.7, 5.8, 1.3}, {9.5, 6.4, 8.1, 4.9, 0.6}, {0.8, 5.7, 2.3, 3.6, 7.8}, {3.9, 6.2, 5.5, 7.8, 2.3} }; All functions and relevant demonstrations should be saved in the file MatrixOp.java. a) Write a function named displayMatrix, which accepts one parameter (a 2D array, i.e., double[][] inputArr). That is, the function header would appear as public static void display Matrix (double[][] inputArr) and display the matrix on your command prompt (in main method) as follows 4.3, 2.7, 8.5, 3.2, 9.8 7.4, 5.6, 3.7, 5.8, 1.3 9.5, 6.4, 8.1, 4.9, 0.6 0.8, 5.7, 2.3, 3.6, 7.8 3.9, 6.2, 5.5, 7.8, 2.3 b) Write a function named rowSum that accepts one 2D array and returns an array of row sum. That is, each element of the returned array should correspond to the sum in each row. The function header would appear as public static double[] rowSum (double[][] inputArr) The correct output would be 28.5, 23.8, 29.5, 20.2, 25.7. Make sure that you print these results in the main method. c) Write a function named colSum that accepts one 2D array and returns an array of column sum. That is, each element of the returned array should correspond to the sum in each column. The function header would appear as public static double[] colSum (double[][] inputArr) The correct output would be 25.9, 26.6, 28.1, 25.3, 21.8. Make sure that you print these results in the main method. d) Write a function named getTrace that accepts one 2D array and returns the trace of the input matrix. Recall that trace of a matrix is defined by summing up all diagonal elements. For instance, the diagonal elements of our sample matrix are 4.3, 5.6, 8.1, 3.6, and 2.3. In terms of 2D array, diagonal elements are those with same row/column indices, i.e., inputArr[i][i]. The function header would appear as public static double getTrace (double[][] inputArr) and the correct result is 23.9. Make sure that you print the trace in the main method

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!