Question: The programming Language is C++ Magic constant = 65 Your program reads a N * N square from the keyboard (3 S=NC=9), then tests to
The programming Language is C++

Magic constant = 65 Your program reads a N * N square from the keyboard (3 S=NC=9), then tests to see if the input square is a magic square. If yes, your program prints a greeting message, otherwise, prints "It is not a Magic Square", and then outputs a magic square. Magic Constant (Magic Sum) = n* (n? + 1)/2 where n is the side length of the square For example: Side length = 3, and then magic constant = 3 . (9+1)/2 = 3.5 - 15 Side length = 5, and then magic constant -5.25 +1)/2=5 13 = 65 Requirements: 1. Your project may contain three files: (1) Magic_Square.h This file contains data and methods: Data: square-2-D array number of columns - store the number of columns number of rows - store the number of rows counter-store a number a Methods: constructor(s)-initialize data members read_data - read data from keyboard print_square-print a magic square is_magic_square-check to see a square is a magic square generate_magic_square-generate a magic square (2) Magic_Square.cpp This file contains your implementation code for your magic square class. Note: you need to include your Magic_Square.h (3) Main.cpp You use this file to test your class. Note: you need to include your Magic_Square.cpp 2. Comment your code properly (10%) 3. Header before your code. (5%) The header include: Your name: : Class: Assignment #: Due date: Instructor: Program Description: 4. Program output (5%) 5. Turn in your program on time. You may suffer 10% deduction per day if you turned in a late project. Your program output may look like: Magic Square Program Enter size of the square: 3 Enter data row by row: 816 3 5 7 4 92 It is a magic square! Magic Square Program Enter the size of the square: 3 Enter data row by row 816 3 5 7 4 29 It is not a Magic Square. The Magic Square is shown: 816 3 5 7 492 Project Assignment #1 Magic Square Focus on: Object Oriented Programming-Class definition and class implementation A Magic Square is a square array of integers such that the sum of every row, the sum of every column, and sum of each diagonal are equal. Task: Define a class, namely MagicSquare, that generates a magic square by the following method. This method works only when the size of the square is an odd number. Starting by placing 1 in the middle of the top row, write down successive integers2, 3, ... along a diagonal going upwards and to the right. When you reach the top tow (as you do immediately since 1 is in the top row.), continuing to the bottom row as though the bottom row were immediately above the top row. When you reach the rightmost column, continue to the leftmost column as though it were immediately to the right of the rightmost one. When you reach a position that is already occupied, instead drop straight down one position from the previous number to insert the new one. The 3 *3 magic square is shown: 8 1 6 3 5 7 4 9 2 Magic constant = 15 The 5 * 5 magic square is shown: 15 17 24 1 8 23 5 7 14 16 46 13 20 22 10 12 19 21 3 11 18 25 2 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
