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.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education