title: Recursive Factorial Java
body: <p>First off, yes this a HW assignment. Having issues with recursive factorials in Java. Everything I'm finding on here and elsewhere already shows me what I've done is correct. However I'm having issues with an additional step. Basically what I need is the 1) User to enter a number 2) Factorial to be calculated 3) If user enters anything but a character or string (rather than an int) for an error message to come out 4) The question to repeat until user enters "0" to exit.</p>
  
  <p>Steps 1 and 2 I have completed. I'm having issues with step 3. It seems like I am missing a return statement if the user enters anything but an int but I can't seem to figure out exactly what.</p>
  
  <p>Here is code thus far:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Recursive
     {
        public static void main(String[] args)
        {
           int number;             // To hold a number
           char letter;            // To hold a character
  
  
           //Create a Scanner object for keyboard input
           Scanner keyboard = new Scanner(System.in);
  
           //Get a number from the user
           System.out.print("Enter an integer to find the factorial: ");
           number = keyboard.nextInt();
  
           //Display the factorial
           System.out.println(number + "! is " + factorial(number));
        }  
  
        private static int factorial(int n)
  
       {
           if (n == 0)
              return 1;     // Base Case
           else if (n &gt; 0)
              return n * factorial(n-1);
           else (!(n&gt;0))
           return
           System.out.println(number + "is invalid");
        }
      }  
  </code></pre>