Please WRITE COMMENTS for each aspect of your JAVA code. Given a square matrix m[3×3], create a java code to calculate the value of its SECONDARY Diagonal. See example below. Hint: In order to better understand the concepts involved in this exercises, research the terms “square matrix” and “secondary diagonal of a matrix” using your favourite search engine. Example given matrix m[3×3] shown below: (0,0) (0,1) (0,2) | 10   12  11 (1,0) (1,1) (1,2) | 9   8   31 (2,0) (2,1) (2,2) | 2   16  24 Secondary Diagonal (generic m[3×3]) = m[0,2] + m[1,1] + m[2,0] Secondary Diagonal (as in the example above) = 11 + 8 + 2 = 21 Note 1: Your java code MUST be GENERIC to calculate the secondary diagonal of ANY square matrix [2×2], [3×3],[4×4], etc. (Use a constant in your code to set the values of numberOfRows and numberOfColumns of your matrix. Note 2: Your matrix may be hardcoded (no need of user interaction) Note 3: In case numberOfRows and numberOfColumns are different, your program must display the following message: “This is not a square matrix.”

Here is the program as per your requirements.
Please note that in java code single line can be commented using //
Alco note that extra code is given you can delete from start to end
// The following program is for calculating secondary diagonal value
public class SecondaryDiagonal // class definition
{
public static void main(String args[]) // main method from where execution starts
{
final int m=3; // constant int defined for rows and initialized as per the requirements.
final int n = 3; // constant int defined for rows and initialized as per the requirements.
int i,j; // integer variable declared
int[][] myMatrix = new int[m][n]; // 2D array is declared which can hold integer values
int value = 0 ; // integer value declared and initialoized to 0
if( m != n ) // if rows and columns are not equal
System.out.println(“This is not a square matrix…. Exiting….”); // display message and stop
else // if m and n are equal then
{
myMatrix[0][0] = 10; // enter value into row 1 and column 1 element
myMatrix[0][1] = 12; // enter value into row 1 and column 2 element
myMatrix[0][2] = 11; // enter value into row 1 and column 3 element
myMatrix[1][0] = 9; // enter value into row 2 and column 1 element
myMatrix[1][1] = 8; // enter value into row 2 and column 2 element
myMatrix[1][2] = 31; // enter value into row 2 and column 3 element
myMatrix[2][0] = 2; // enter value into row 3 and column 1 element
myMatrix[2][1] = 16; // enter value into row 3 and column 2 element
myMatrix[2][2] = 24; // enter value into row 3 and column 3 element
// start
// this is for your convenience i.e to add different values into the matrix
// for (i = 0; i
 
“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”

What Students Are Saying About Us

.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐
"Honestly, I was afraid to send my paper to you, but splendidwritings.com proved they are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"

.......... Customer ID: 14***| Rating: ⭐⭐⭐⭐⭐
"The company has some nice prices and good content. I ordered a term paper here and got a very good one. I'll keep ordering from this website."

"Order a Custom Paper on Similar Assignment! No Plagiarism! Enjoy 20% Discount"