Question: please answer in java and add comments. please answer as soon as possible . thank you so much Question 1: Magic Matrix A magic square

 please answer in java and add comments. please answer as soon

as possible . thank you so much Question 1: Magic Matrix A

please answer in java and add comments. please answer as soon as possible . thank you so much

Question 1: Magic Matrix A magic square is an n x n matrix that has the following 2 properties: 1) It is filled with the numbers 1,2,3,....., n?, and each number occurs once and only once. 2) The sum of the elements in each row, in each column, and in the two diagonals is the same value. An example of magic square is as follows. 6 7 2 1 8 5 3 9 4. You are asked to write a Java code that can randomly generate one magic square. Your code will randomly generate a 3x3 matrix that satisfies 1) and then check if the matrix satisfies 2); If not, the Java code will continue generating another random matrix that satisfies 1) until a generated matrix that satisfies 2). Sample outputs could be as follows: Sample 1: The randomly generated matrix is: 4 3 8 9 5 1 2. 7 6 Sample 1: The randomly generated matrix is: 4 3 8 9 5 1 2 7 6. Sample 2: I The randomly generated matrix is: 4 9 2 3 5 7 8 1 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!