import java.io.*;
public class Magic{
static final int maxsize = 50;
public static void main (String [] args) throws IOException{
int i, j, k, l, n, key;
Put your code that computes your magic square in a separate method, and have your input reading code in a while loop, that calls that method until the user presses N, for example.