Question: JAVA Create a new java project called MagicSquare. Create a new class in the project named MagicSquare You will do all of your work in

JAVA

JAVA Create a new java project called MagicSquare. Create a new class

Create a new java project called MagicSquare. Create a new class in the project named MagicSquare You will do all of your work in MagicSquare.java!!! Download the TestMagicSquare.java file (TestMagicSquare.java)into the src folder of your project (If the download does not work, create a new class TestMagicSquare in your project and then copy the contents of TestMagicSquare into that file). Until you complete the next step, TestMagicSquare will have a red x because it wants to call isMagicSquare in MagicSquare.java Now, in MagicSquare.java create a method isMagicSquare that takes a two dimensional integer array as a parameter and returns a boolean isMagicSquare will return whether the array passed in is a magic square. The array is a magic square if it is square in shape (same number of rows as columns), and all of its row, column, and diagonal sums are equal. For example, [[2, 7, 6), (9,5, 1], [4, 3, 8]] is a magic square because all eight of the sums are exactly 15. The square can be any size 3x3, 5x5 etc. You can run the code in TestMagicSquare to test your code. 2D Array Programming Hints 1. Use indices like row/coli.e. array (row] (col) instead of 1/1 (array[i] [5]). 2. row is ALWAYS limited by array.length 3. col is ALWAYS limited by array[0].length 4. Using a 3x3 array, write the access pattern you will be using for one traversal. a. If you were adding up the values in the columns, the first traversal is: [0][0], [2010], [2][0] The value that does not change is your outer loop: for (int col = 0; col

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!