The Lo Shu Magic Square The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below:     The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 through 9 exactly. The sum of each row, each column, and each diagonal all add up to the same number. This is shown below:     Write a program that simulates a magic square using 3 one-dimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not.   See the sample outputs for more clarification.   Project Specifications   Input for this project:   Values of the grid (row by row)   Output for this project:   Whether or not the grid is magic square Programmer’s full name Project number Project due date     Processing Requirements   Start from scratch. Use the following template to start your project:   #include using namespace std;   // Global constants const int ROWS = 3;  // The number of rows in the array const int COLS = 3;  // The number of columns in the array const int MIN = 1;  // The value of the smallest number const int MAX = 9;  // The value of the largest number   // Function prototypes bool isMagicSquare(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size); bool checkRange(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size, int min, int max); bool checkUnique(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size); bool checkRowSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size); bool checkColSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size); bool checkDiagSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size); void fillArray(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size); void showArray(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size);   int main() {               /* Define a Lo Shu Magic Square using 3 parallel arrays corresponding         to each row of the grid */         int magicArrayRow1[COLS], magicArrayRow2[COLS], magicArrayRow3[COLS];         // Your code goes here         return 0; } // Function definitions go here       Do not repeat any source code segment you submitted in previous semesters. Create and use at least the following functions:   void fillArray(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size) - Accepts 3 int arrays and a size as arguments, and fills the arrays out with values entered by the user. First argument corresponds to the first row of the magic square, second argument to the second row and the third argument to the third row of the magic square void showArray(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size) - accepts 3 int arrays and a size as arguments and displays their content. Example:      1 3 5    (arrayRow1)  6 7 9    (arrayRow2)  8 2 4    (arrayRow3)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section4.5: A Case Study: Solving Quadratic Equations
Problem 2E
icon
Related questions
Question

C + +

 

Project Description

 

The Lo Shu Magic Square

The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below:

 

 

The Lo Shu Magic Square has the following properties:

  • The grid contains the numbers 1 through 9 exactly.
  • The sum of each row, each column, and each diagonal all add up to the same

number. This is shown below:

 

 

Write a program that simulates a magic square using 3 one-dimensional parallel arrays of integer type.

Each one the arrays corresponds to a row of the magic square.

The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not.

 

See the sample outputs for more clarification.

 

Project Specifications

 

Input for this project:

 

  • Values of the grid (row by row)

 

Output for this project:

 

  • Whether or not the grid is magic square
  • Programmer’s full name
  • Project number
  • Project due date

 

 

Processing Requirements

 

Start from scratch.

Use the following template to start your project:

 

#include<iostream>

using namespace std;

 

// Global constants

const int ROWS = 3;  // The number of rows in the array

const int COLS = 3;  // The number of columns in the array

const int MIN = 1;  // The value of the smallest number

const int MAX = 9;  // The value of the largest number

 

// Function prototypes

bool isMagicSquare(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size);

bool checkRange(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size, int min, int max);

bool checkUnique(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size);

bool checkRowSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size);

bool checkColSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size);

bool checkDiagSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size);

void fillArray(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size);

void showArray(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size);

 

int main()

{

     

        /* Define a Lo Shu Magic Square using 3 parallel arrays corresponding         to each row of the grid */

        int magicArrayRow1[COLS], magicArrayRow2[COLS], magicArrayRow3[COLS];

        // Your code goes here

 

      return 0;

}

// Function definitions go here

 

 

 

Do not repeat any source code segment you submitted in previous semesters.

Create and use at least the following functions:

 

  • void fillArray(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size) - Accepts 3 int arrays and a size as arguments, and fills the arrays out with values entered by the user. First argument corresponds to the first row of the magic square, second argument to the second row and the third argument to the third row of the magic square
  • void showArray(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size) - accepts 3 int arrays and a size as arguments and displays their content.

Example:    

 1 3 5    (arrayRow1)

 6 7 9    (arrayRow2)

 8 2 4    (arrayRow3)

Sample Output
Enter the nunber for row 8 and column 0 :1
Enter the nunber for row 0 and column 1 :3
Enter the nunber for row 8 and column 2 :2
Enter the nunber for row 1 and column 8 :5
Enter the number for row 1 and column 1 :4
Enter the nunber for row 1 and column 2 :9
Enter the nunber for row 2 and column 0 :6
Enter the number for row 2 and column 1 :?
Enter the nunber for row 2 and column 2 :8
1 3 2
5 49
6 78
This is not a Lo Shu magic square.
Do you want to try again?y
Enter the number for row and column 8 :10
Enter the number for row 0 and column 1 :2
Enter the number for row 0 and column 2 :3
Enter the number for row 1 and colunn 0 :4
Enter the number for row 1 and column 1 :15
Enter the number for row 1 and colunn 2 :6
Enter the nunber for row 2 and column 0 :7
Enter the number for row 2 and colunn 1 :8
Enter the nunber for row 2 and colunn 2 :-8
10 2 3
4 15 6
78 -8
This is not a Lo Shu nagic square.
Do you want to try again?y
Enter the nunber for row è and colunn 0 :4
Enter the number for row 0 and column 1 :9
Enter the number for row 0 and column 2 :2
Enter the nunber for row 1 and colunn 0 :3
Enter the nunber for row 1 and colunn 1 :5
Enter the number for row 1 and colunn 2 :7
Enter the nunber for row 2 and colunn 0 :8
Enter the nunber for row 2 and colunn 1 :1
Enter the nunber for row 2 and colunn 2 :6
49 2
357
816
This is a Lo Shu nagic square.
Do you want to try again?n
Press any key to continue
..
Name:
Project #:
Due Date:
Press any key to continue
Transcribed Image Text:Sample Output Enter the nunber for row 8 and column 0 :1 Enter the nunber for row 0 and column 1 :3 Enter the nunber for row 8 and column 2 :2 Enter the nunber for row 1 and column 8 :5 Enter the number for row 1 and column 1 :4 Enter the nunber for row 1 and column 2 :9 Enter the nunber for row 2 and column 0 :6 Enter the number for row 2 and column 1 :? Enter the nunber for row 2 and column 2 :8 1 3 2 5 49 6 78 This is not a Lo Shu magic square. Do you want to try again?y Enter the number for row and column 8 :10 Enter the number for row 0 and column 1 :2 Enter the number for row 0 and column 2 :3 Enter the number for row 1 and colunn 0 :4 Enter the number for row 1 and column 1 :15 Enter the number for row 1 and colunn 2 :6 Enter the nunber for row 2 and column 0 :7 Enter the number for row 2 and colunn 1 :8 Enter the nunber for row 2 and colunn 2 :-8 10 2 3 4 15 6 78 -8 This is not a Lo Shu nagic square. Do you want to try again?y Enter the nunber for row è and colunn 0 :4 Enter the number for row 0 and column 1 :9 Enter the number for row 0 and column 2 :2 Enter the nunber for row 1 and colunn 0 :3 Enter the nunber for row 1 and colunn 1 :5 Enter the number for row 1 and colunn 2 :7 Enter the nunber for row 2 and colunn 0 :8 Enter the nunber for row 2 and colunn 1 :1 Enter the nunber for row 2 and colunn 2 :6 49 2 357 816 This is a Lo Shu nagic square. Do you want to try again?n Press any key to continue .. Name: Project #: Due Date: Press any key to continue
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage