Square Matrix

$5.99

Category:

Description

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:

square matrix

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 m may be hardcoded (no need of user interaction)

Note 3: In case numberOfRows and numberOfColumns ar differents, your program must display the following message: “This is not a square matrix.”

Solution provided in PDF form. Not source code.