```
/****************************************
*File Name: Assignment 4 Part 1
*Purpose: An n x n matrix that is filled with the numbers 1, 2, 3, . . . n^2 is a magic square if the sum of
*the elements in each row, in each column, and in the two diagonals is the same value.
* 16 3 2 13
* 5 10 11 8
* 9 6 7 12
* 4 15 14 1
*Write a program that generates 16 values between 1 and 16 (no duplicates allowed) and tests whether they form
*a magic square when put into a 4 X 4 array. You need to test two features:
* Does each of the numbers 1, 2, . . ., 16 occur in the user input?
* When the numbers are input into a square, are the sums of the rows, columns, and diagonals equals to each other?
*Programmer: Shanel Fowler
*Last Updated Date: 3/16/14
****************************************/
import java.util.*;
public class Assignment_4_01
{
boolean Duplicate = false; //Creates a boolean variable that stores.
static final int ROW = 4; //Creates an integer for the number of rows.
static final int COL = 4; //Creates an integer for the number of columns.
/**
*Method will determine whether or not there are any duplicates within the
*matrix. If the number is randomly generated again, another will take its
*place within the designated range.
*/
public static boolean isDuplicate(int[][] value)
{
for(int a = 0; a < value.length; a++)
{
for(int b = 0; b < value.length; b++)
{
boolean repeat = false;
int num;
while(repeat)
{
}
}
}
}
public static void main(String[] args)
{
int [][] squareArray = new int[ROW][COL]; //Creates a two dimensional array to store values.
int minNum = 1; //Creates an integer set to the minimum value.
int maxNum = 16; //Creates an integer set to the maximum value.
Random randNum = new Random(); //Creates random variable.
//Allocates a random value into each column and row in the 4 X 4 matrix.
for(int r = 0; r < ROW; r++)
{
for(int c = 0; c < COL; c++)
{
int tempVal = randNum.nextInt(maxNum - minNum + 1) + minNum;
squareArray[r][c] = tempVal;
}
}
for(int i = 0; i < squareArray.length; i++)
{
for(int x = 0; x < squareArray.length; x++)
{
System.out.print(squareArray[i][x]);
System.out.print(" ");
}
System.out.println();
}
}
}
```