class Magic_Square
{
private:
int Size; // Number of rows and columns in the Magic Square array
int MagSq[5][5]; // Magic Square matrix
int ColSums[5]; // Array of column sums
int RowSums[5]; // Array of row sums
int Diag1; // Sum of major diagonal
int Diag2; // Sum of minor diagonal
bool Sum_Criteria; // Was the sum test met?
bool Sequence_Criteria; // Was the sequence test met?
void Calc_RowSums(); // Calculates the row sums
void Calc_ColSums(); // Calculates the column sums
void Calc_Diags(); // Calculates the two diagonal sums
public:
Magic_Square(); // Constructor initializes all member variables
void Input_Values(); // Reads the input matrix values
void Output_Values(); // Writes the output matrix values
void Seq_Test(); // Determines if the sequence test was met
void Sum_Test(); // Determines if the sum test was met
void Evaluate(); // Determines and generates message whether a magic square or not. If not, generates message about which criteria failed
}
Here's the outline of the class I've been given to create a program that tests magic squares. A magic square has dimensions nXn (in this case 5X5). Numbers can only go up to 25 and can only be used once. The numbers in all directions must add up to the same number. This program will be tested using input from a .DAT file and will print the values of the array and whether it's a magic square or not to an output file.