Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

As early as 650 BC, mathematicians had been composing magic squares, a sequence of n numbers arranged in a square such that all rows, columns,

As early as 650 BC, mathematicians had been composing magic squares, a sequence of n numbers arranged in a square such that all rows, columns, and diagonals sum to the same constant.

Used in China, India, and Arab countries for centuries, artist Albrecht Durers engraving Melencolia I (1514 C.E.) is considered the first time a magic square appears in European art. Each row, column, and diagonal of Durers magic squaresums to 34. In addition, each quadrant, the center four squares, and the corner squares all sum to 34. Durers magic square is displayed below:

16

3

2

13

5

10

11

8

9

6

7

12

4

15

14

1

At various times they have acquired magical or mythical significance, and have appeared as symbols in works of art. In modern times they have been generalized several ways, including using extra or different constraints, multiplying instead of adding cells, using alternate shapes or more than two dimensions, and replacing numbers with shapes and addition with

geometric operations.

You will develop a program to prove a series of numbers is indeed a 4 x 4 magic square.

TASK 1: Matrix size Prompt the user to enter their proposed magic square in a single input statement (e.g. [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16] note that this example is a 4 x 4 matrix but is not a magic square). Determine if the matrix entered is a 4 x 4. If it is not, inform the user of their mistake and prompt the user to re-enter another matrix. Repeat this check until the user successfully enters a correctly sized matrix.

TASK 2: Whole numbers Check that each value in the matrix is a whole number. If it is not, prompt the user to round the number up or down (see example menu statements). Based on their choice, replace the decimal number with the rounded whole value.

TASK 3: Positive numbers Check that each value in the matrix is a positive number. Create a formatted output for the number of nonpositive values found. For each nonpositive value, prompt the user to replace it with a positive whole number. If the user does not enter a valid number, continue prompting the user until a positive whole number is entered.

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

More Books

Students also viewed these Databases questions

Question

Distinguish between filtering and interpreting. (Objective 2)

Answered: 1 week ago