Menu

(Solved) : Given Square Matrix M 3×3 Create Java Code Calculate Value Secondary Diagonal See Example Q29623468 . . .

Given a square matrix m[3×3], create a java code to calculatethe value of its SECONDARY Diagonal. See example below.

Hint: In order to better understand the concepts involved inthis exercises, research the terms “square matrix” and “secondarydiagonal 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 thesecondary diagonal of ANY square matrix [2×2], [3×3],[4×4], etc.(Use a constant in your code to set the values of numberOfRows andnumberOfColumns of your matrix.

Note 2: Your matrix m may be hardcoded (no need of userinteraction)

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

Expert Answer


Answer to Given Square Matrix M 3×3 Create Java Code Calculate Value Secondary Diagonal See Example Q29623468 . . .

OR