Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm in java one and need help with this code. please follow the given directions and test your program to make sure it works as

I'm in java one and need help with this code. please follow the given directions and test your program to make sure it works as it is required.please use a 2 dimentional array . I will apreciate your help. thank you

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

A magic square is an arrangement of the numbers from 1 to n2 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(n2+1)/2. Here is an example 4x4 magic square. Notice that all of the rows add up to 34 [which is (4*(42+1))/2], all of the columns add up to 34, and both of the main diagonals add up to 34. Also notice that each of the numbers from 1 through 16 is used only once each in the square and that only the numbers 1 through 16 are used 16 4 15 13 12 14 7 10 6 For this program, you are going to allow the user to enter the values for a 4x4 magic square and then validate the rows, columns and diagonals of the matrix to see if it is a magic square or not. Your program will process 4x4 squares, though it should be easy to make your program handle any nxn array. Your program will prompt for the user to enter the four values for each row, row-by-row. Your program should output complete, detailed reasons as to why the square isn't a magic square. See the example runs for an idea of input and output. FINAL OUTPUT Please see the "Grading Notes" section at the end of this assignment for the order of final output that must be produced. Irn addition to the output from the methods below, as its final output, your program must print one of the following statements on a line by itself, exactly as you see here: MAGIC: YES if the square is determined to be a magic square MAGIC: NO if the square is determined to not be a magic square

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

Explain the difference between opportunities and ideas.

Answered: 1 week ago