Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA. Please follow the instructions (Ignore the parts concerning TestMagicSquare and the files) Create a new java project called MagicSquare. Create a new class in

JAVA. Please follow the instructions (Ignore the parts concerning "TestMagicSquare" and the files)

image text in transcribed

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

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago