Lab15a Java Assignment AP Computer Science The "Magic Square" Program 80, 100 & 110 Point Versions Assignment Purpose: The purpose of this program is to manipulate two-dimensional static arrays. Write a program that creates odd-sized Magic Squares. A magic square is a square matrix of consecutive numbers, such that the numbers in the rows, the numbers in the columns, and the numbers in the diagonals add up to the same sum. For this program you will only be concerned with magic squares. Odd-sized refers to the size of the matrix, such as a 3 X 3, a 5 X 5, and “odd-sized” 9 X 9 or 13 X 13 sized matrix. Examples of a 3 X 3 magic square and a 5 X 5 magic square are shown below: 8 1 6 3 5 7 4 9 2 Every row, column and diagonal in the 3 X 3 matrix adds up to 15. 17 24 1 8 14 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 Every row, column and diagonal in the 5 X 5 matrix adds up to 65. The magic square program is quite challenging, and comes in two different levels of difficulty. It is very important that you first are able to create magic squares, of any odd size, yourself on paper. On the next page is a five-step algorithm to create an odd magic square. Study these steps carefully and use them to create magic squares on paper. Only after you are confident that you understand the magic square algorithm, are you ready to proceed to write a program.
AP Computer Science Lab15a Java Assignment The "Magic Square" Program 80, 100 & 110 Point Versions Assignment Purpose: The purpose of this program is to manipulate two-dimensional static arrays. Write a program that creates odd-sized Magic Squares. A magic square is a square matrix of consecutive numbers, such that the numbers in the rows, the numbers in the columns, and the numbers in the diagonals add up to the same sum. For this program you will only be concerned with “odd-sized” magic squares. Odd-sized refers to the size of the matrix, such as a 3 X 3, a 5 X 5, and 9 X 9 or 13 X 13 sized matrix. Examples of a 3 X 3 magic square and a 5 X 5 magic square are shown below: 8 1 6 3 5 7 4 9 2 Every row, column and diagonal in the 3 X 3 matrix adds up to 15. 17 24 1 8 14 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 Every row, column and diagonal in the 5 X 5 matrix adds up to 65. The magic square program is quite challenging, and comes in two different levels of difficulty. It is very important that you first are able to create magic squares, of any odd size, yourself on paper. On the next page is a five-step algorithm to create an odd magic square. Study these steps carefully and use them to create magic squares on paper. Only after you are confident that you understand the magic square algorithm, are you ready to proceed to write a program.