Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part B [15 points]: This assignment extends from Part A that you have implemented previously. Recall that in Part A, a grid is drawn for

image text in transcribed
image text in transcribed
Part B [15 points]: This assignment extends from Part A that you have implemented previously. Recall that in Part A, a grid is drawn for filling in a 4 x 4 square of cells containing integers. For this part of the assignment, first you will need to implement a method that verifies whether a given 4 x 4 square (containing 16 values) is a Magic Square. A Magic Square for the purpose of this assignment is that the values in any horizontal row, vertical column or main diagonals add up to the same value. You will be using 2-dimensional arrays for storing and processing the values stored in a square. Here is the header for the above method: 1 * * This method verifies whether a given square is a magic square or not parameter squareData is a symmetrical 2 - dimensional array of integers * returns true if the square is magic if all rows or columns , or two main diagonals add up to same value * return false otherwise private static boolean isSquareMagic (int squareData ) ; Notes : 1. Implement the above method in the same class from Part A ( MagicSquare .java ) 2. Once implemented , test this method with squares that are both magic and otherwise . In other words, call this method from the main method in class MagicSquare .java 3. For testing, you need data. For a valid Magic Square, use the data from the grid below: CSC 142 Magic Square 4. For example, here is how the values in the above grid can be stored in using a 2-dimensional array: int squareData = {{8, 11, 14, 1 }, {13,2,7, 12 }, {3, 16,9,6 }, ( 10,5, 4, 15 }}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Optics

Authors: Eugene Hecht

5th edition

133977226, 133979121, 978-0133977226

More Books

Students also viewed these Physics questions