Hi...
I really need help in my hw because it will be submetted tommorow .

Problem # 2:

Write a Java application that test whether a two dimensional array, input by the user, is a magic square. A magic square is an NxN matrix of numbers in which every number from 1 to N2 must appear just once, and every row, column, and diagonal must add up to the same total – for example,

6   7   2
1   5   9
8   3   4         is a magic square.

To check the magic square you need to use method check that will take the two dimensional array and return true if it’s a magic square and false other wise. Restrict the matrix size to any size smaller than 10X10
Sample Run:

What is the size of your matrix (value of N): 3
Enter row 0: 6 7 2
Enter row 1: 1 5 9
Enter row 2: 8 3 4
This is a magic square

Recommended Answers

All 2 Replies

See reply to post 3

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.