Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A magic square is an arrangement of numbers in such a way that every row, every column, and both diagonals have the same sum. For

A magic square is an arrangement of numbers in such a way that every row, every column, and both diagonals have the same sum. For example this square has a such of sum of 15:
492
357
816
Write a method that will take a 2D arary as an argument and determine whether or not it is a magic square. For example, in the Java code below array1 is not a magic square but array2 is.
int [][] array1={{5,7,3,1},
{16,15,14,13},
{2,4,6,8},
{10,11,12,9}};
int [][] array2={{6,32,3,34,35,1},
{7,11,27,28,8,30},
{19,14,16,15,23,24},
{18,20,22,21,17,13},
{25,29,10,9,26,12},
{36,5,33,4,2,31}};

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

Students also viewed these Databases questions