title: How to Calculate the factorial of a decimal number in Java?
body: <p>I did a function to calculate the factorial of a number , but when i writes a decimal number or a character the "mini-application" does not work. How can i calculate the factorial of a decimal and launch a message error to the user when he writes a character .?</p>
  
  <pre><code> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       // BOTON CALCULAR
  
       String valortextfield = jTextField1.getText();
       int numero = Integer.parseInt(valortextfield);
       Metodos metod = new Metodos();
  
       BigInteger resultado = metod.factorial(numero);
       String valorAmostrar= resultado.toString();
  
       jTextArea1.setText(valorAmostrar);
  
      }    
  </code></pre>
  
  <p>the method :</p>
  
  <pre><code>public class Metodos {
  
      public BigInteger factorial (int numero ){
      if ((numero &lt; 0)||(numero &gt;50)) {
  
          return BigInteger.ZERO;
  
  
      } else if (numero==0){
  
          return BigInteger.ONE;
  
      } else {
          return BigInteger.valueOf(numero).multiply(factorial(numero-1));
      }
  }
  </code></pre>
  
  <p>Thanks.</p>