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."