Hi everyone! This is my first time posting on this website. I'm a beginner in
java. I am facing a problem solving the following:
"A magic square is an arrangement of the numbers from 1 to n^2 (n-squared) in an nxn matrix, with each number occurring exactly once, and such that the sum of the entries of any row, any column, or any main diagonal is the same. It is not hard to show that this sum must be n(n^2+1)/2. Magic squares have been around since 650 BC (China) ! For those who are interested, this Wikipedia article provides more background.
You should add code to Magic.java to check that each column equals the n(n^2+1)/2. Currently, the Magic.java program does an incomplete job of determining all the necessary checks for satisfying the conditions of a Magic Square. In particular, it does not check that the sum of each column equals n(n^2+1)/2 You may find it useful to look at how the row sums were computed."
Here's the code for the magic square:
I would really appreciate any help! Thank you in advance!