Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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

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_2

Step: 3

blur-text-image_3

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago