title: Fibonacci numbers- input
body: <p>On this program, how do i keep asking the user if he/she wants to find another number? It only works once. Should I use a while loop? How to set that up? I am confused. Thanks.</p>
  
  <pre><code>public class FibonacciNUmbers
  {
  
  public static int calcFibNum(int x)
  {
   if (x == 0)
     return 0;
   else if (x == 1)
     return 1;
   else
     return calcFibNum(x-1) + calcFibNum(x-2);
   }
  
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    System.out.println("What number would you like to find the Fibonacci number for?");
    int x = in.nextInt();
    System.out.println("The " + x + "th Fibonacci number of " + x + " is " + calcFibNum(x));
  
    String answer = "Y"; 
    while (answer.equals("Y"))
    {
       System.out.println("Would you like to find the Fibonaci number of another number?(Y/N)");
       answer = in.next(); //declare your variable answer outside the loop so you  can use it in the evaluation of how many times to do the loop.
    if (answer.equalsIgnoreCase("Y"))
    {
     System.out.println("What number would you like to find the Fibonacci number for?");
     x = in.nextInt();
     System.out.println("The Fibonacci number for " + x + " is " + calcFibNum(x));
    }
    else if (answer.equalsIgnoreCase("N"))
       System.out.println();
  
    }
  
  
  }
  </code></pre>
  
  <p>}</p>