This lab will focus on populating and traversing a two-dimensional array (matrix). Consider a 3 by 3 square containing values Vị to V9 as shown below; conveniently, these values can be represented using a matrix (two-dimensional array). Vi V2 V3 V4 Vs V6 V7 Ve 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 + Ve + 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 + Ve = 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 the input matrix has a particular number of sides. As a positive test example, use the following magic matrix. We verify that the matrix is magic by noting that 1 + 5 + 9 = 159 8 34 6 72 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.
This lab will focus on populating and traversing a two-dimensional array (matrix). Consider a 3 by 3 square containing values Vị to V9 as shown below; conveniently, these values can be represented using a matrix (two-dimensional array). Vi V2 V3 V4 Vs V6 V7 Ve 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 + Ve + 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 + Ve = 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 the input matrix has a particular number of sides. As a positive test example, use the following magic matrix. We verify that the matrix is magic by noting that 1 + 5 + 9 = 159 8 34 6 72 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.
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 12PP: (Data processing) The answers to a true-false test are as follows: T T F F T. Given a twodimensional...
Related questions
Question
Java
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning