Magic squares. an n x n matrix that is filled with the numbers 1,2,3...,n2 is a
ID: 3621988 • Letter: M
Question
Magic squares. an n x n matrix that is filled with the 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.Write a program that reads n2 values from the keyboard and tests wether they form a magic square when arranged as a square matrix. You need to test three features:
Did each user enter n2 numbers for some n?
Do each of the numbers 1,2,...,n2 occur exactly once in the user input?
When the numbers are put into a square, are the sums if the rows, columns, and diagonals equal to each other?
if the size of the input is a square, test wether all numbers between 1 and n2 are present. Then conpute the row, column, and diagonal sums. Implement a class Square with methods: public void add(int i) and public boolean isMagic()
not really sure how to do this problem your help is great.