title: Java: How to ask user if he/she wants to continue program
body: <p>I've already made it so that it will tell whether the input from the user is a prime number or not a prime number but now I have to make it so that it will ask the user if he/she wants to check another number and wait for the user to enter "Y" or "y" as yes, "n" or "N" as no. If yes, repeat the three steps. If no, exit the program. For all other letters, reject ti and ask the user to enter only "y" or "n". </p>
  
  <pre><code>import java.util.*;  // importing package util
  
  
  public class Prime
  {
      public static void main (String args[])
      {
          int num,count=0;
          Scanner scan = new Scanner(System.in); //scanner for input
          System.out.print("Enter any number : ");
          num = scan.nextInt();
          for(int i=2; i &lt;= (num/2); i++) 
          {
              if((num % i) == 0)
              {
                  count++;
                  break;
              }
          }
          if((count==0) &amp;&amp; (num!= 1))
          System.out.println( num + " is a prime number.");
          else
          System.out.println( num + " is not a prime number.");
      }
  }
  </code></pre>