Cs101: Lab #17 Arrays Part II This lab will focus on populating and traversing a two-dimensional array (matrix). Consider a 3 by 3 square containing values V1 to V9 as shown below; conveniently, these...


Java


Cs101: Lab #17<br>Arrays Part II<br>This lab will focus on populating and traversing a two-dimensional array (matrix).<br>Consider a 3 by 3 square containing values V1 to V9 as shown below; conveniently, these values can be<br>represented using a matrix (two-dimensional array).<br>V1 V2 V3<br>V4 Vs Ve<br>Vi V8 V9<br>A square is said to be row semi-magic if the values in each of the rows sum to the same value:<br>(Vi + V2 + V3 = V4 + Vs + V6 = V7 + V8 + V9).<br>A square is said to be column semi-magic if the values in each of the columns sum to the same value:<br>(Vi + V4 + V7 = V2 + Vs + V8 = V3 + V6 + V9).<br>A matrix is said to be magic if the matrix is semi-magic in terms of its rows and its columns. Complete<br>the three corresponding methods that determine if the given matrix is column semi-magic, row semi-<br>magic, and magic. You may not assume<br>input matrix has a particular number of sides.<br>As a positive test example, use the following<br>We verify that the matrix is magic by noting<br>magic matrix.<br>that<br>1<br>1 + 5 + 9 =<br>8<br>6 7<br>2<br>8 + 3 + 4 =<br>6 + 7 + 2 = 15<br>= 1 + 8 + 6<br>= 5 + 3 + 7<br>= 9 + 4 + 2<br>Implement a Matrix class with a matrix as an attribute and the necessary methods. The constructor<br>should throw an exception if the input matrix is not square.<br>Also implement a Tester class that constructs and initializes a Matrix object and tests whether the<br>matrix is magic.<br>

Extracted text: Cs101: Lab #17 Arrays Part II This lab will focus on populating and traversing a two-dimensional array (matrix). Consider a 3 by 3 square containing values V1 to V9 as shown below; conveniently, these values can be represented using a matrix (two-dimensional array). V1 V2 V3 V4 Vs Ve Vi V8 V9 A square is said to be row semi-magic if the values in each of the rows sum to the same value: (Vi + V2 + V3 = V4 + Vs + V6 = V7 + V8 + V9). A square is said to be column semi-magic if the values in each of the columns sum to the same value: (Vi + V4 + V7 = V2 + Vs + V8 = V3 + V6 + V9). A matrix is said to be magic if the matrix is semi-magic in terms of its rows and its columns. Complete the three corresponding methods that determine if the given matrix is column semi-magic, row semi- magic, and magic. You may not assume input matrix has a particular number of sides. As a positive test example, use the following We verify that the matrix is magic by noting magic matrix. that 1 1 + 5 + 9 = 8 6 7 2 8 + 3 + 4 = 6 + 7 + 2 = 15 = 1 + 8 + 6 = 5 + 3 + 7 = 9 + 4 + 2 Implement a Matrix class with a matrix as an attribute and the necessary methods. The constructor should throw an exception if the input matrix is not square. Also implement a Tester class that constructs and initializes a Matrix object and tests whether the matrix is magic.

Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here