Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MAGIC SQUARE JAVA PROGRAM I have tried using a one dimensional array for this problem but I am running into some heavy issues. I have

MAGIC SQUARE JAVA PROGRAM

image text in transcribed

I have tried using a one dimensional array for this problem but I am running into some heavy issues. I have seen examples of two dimensional magic square programs online, but I have been trying to do it in one-dimension considering my professor said it could be done.

Program Specification An n x n matrix that is filled with the whole numbers 1, 2, 3, .. n2 is a magic square if the sum of the elements in each row, in each column, and in the two diagonals is the same value Here is a magic square where n = 3 4 Write a program that reads n2 numbers from standard input and tests whether they form a magic square when put into matrix form. The value of n is NOT an input to the program; n must be determined from the number of inputs. For example, the input that creates the example matrix above is 8163 5749 2. The output is a single word, "true" if the input produces a magic square, "false" otherwise. Your program may assume that each input token is a whole number The program must verify: Th e proper number of input values was provided. 2.Each of the numbers between 1 and n occurs exactly once in the input. When the numbers are arranged in a matrix, the sum of the rows, columns, and diagonals must be the same value

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

5 Explain how sentence style affects emphasis within your message

Answered: 1 week ago

Question

Explain competency models and the process used to develop them.

Answered: 1 week ago

Question

What is Third Party Payment at is Third Party Payment.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago