Magic Squares
OBJECTIVES:
The student will become familiar with organizing data in tabular form (2-D arrays), counting and the concept of wrap-around.
DESCRIPTION:
Create a MAGIC SQUARE, which must be of size 5 (rows and columns) or greater and must be an ODD number. A MAGIC SQUARE has the same SUM for each of its rows, columns and major diagonals.
Use a Object approach to build this solution.
Input:
Size of square (5 x 5, 7 x 7 or greater).
Starting number .
Increment (amount to add on each time).
Output:
The input information with a description for each.
The "MAGIC SQUARE" properly spaced.
Sample Output:
Size 5
Starting Number 1 Increment 1
MAGIC SQUARE
Rules:
Start with the top row and middle column.
Move up one row and right one column.
If you go off the top come back on the bottom.
If you go off the right side come back on the left side.
If a square is already used then use the square below the previous square.