%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Student Name: Tommy Gober
% COURSE: COSC4153
% ASSIGNMENT: MAGIC TEST
% FILE: MagicTest.m
% PURPOSE:
%   Calculates values in Magic Square to test if input is magic square
%   Tested up to Magic Squares in the thousands.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

display(' ');
userSquare = input('Enter a matrix: ');
%i had alot of garbage here but i found out MATLAB handles alot for you!

%grab sum along each dimention
sum_vert = sum(userSquare);
sum_hori = sum(userSquare');
sum_diag = sum(diag(userSquare));

%check that sum values are the same...
if (sum_vert == sum_hori)
    %also check the diagonal...
    if (sum_vert(1) == sum_diag(1))
        %tell the user it is a good square
        fprintf('Magic Square sum is: %d\n', sum_vert(1));
    end
else
    %inform user it is not a good square
    display('You have not entered a Magic Square');
end