How do I make my code run in a loop and ask the user "Try again Yes or no?"
<pre><code>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;
      boolean n_ok;
      String line;
      int [] [] square = new int [maxsize] [maxsize];

      BufferedReader KeybIn = new BufferedReader(new InputStreamReader(System.in));

      try{


         System.out.print("Size of square? ");
         line  = KeybIn.readLine();
         n = Integer.parseInt(line);

         n_ok = (1&lt;=n) &amp; (n&lt;=maxsize+1) &amp; (n%2==1);


         if ( n_ok ){


            for (i=0;i&lt;n;i++)
               for (j=0;j&lt;n;j++) square[i][j] = 0;
            square[0][(int)(n-1)/2] = 1;

            key = 2;
            i = 0;
            j = (int)(n-1)/2;
            while ( key &lt;= n*n ){

               k = i - 1;

               if ( k &lt; 0 ) k = k + n;
               l = j - 1;

               if ( l &lt; 0 ) l = l + n;

               if ( square[k][l] != 0 ) i = (i+1) % n;

               else { i = k; j = l; }
               square[i][j] = key;
               key = key + 1;
            }


            System.out.println("Magic square of size " + n);

            for (i=0;i&lt;n;i++)

            {

               for (j=0;j&lt;n;j++)
                  System.out.print("\t"+square[i][j]);
               System.out.println();
            }
         }      
      }catch (NumberFormatException e){

         System.out.println("Error in number, try again.");

      }

   }
}
</code></pre>

<p>So how do I put the "Try again yes or no"? just that.. then if I enter y .. it will ask the user the size of the square again .. if letter n it will exit .. this is for magic square</p>
