All pastes #454590 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-04-23 18:23 UTC
rendered paste body
/* 
Purpose:
            This program computes the factorial(faculteit) of a given value
            
    Record of revision:
           Date                   Programmer:              Description
           ====                   ===========              ===========
           18-04-07               M.Helmijr                Original code

*/

import javax.swing.*;
public class Faculteit  {

       //define method
       public static void main(String [] args)throws Exception  {
                                                                  	

      //Declares variables
      int k;                                                    //integer van een getal
      int facul;                                               //kwadraat van het getal
      int value;                                               //input value
      String str;

      //Promt user for an value
      str = JOptionPane.showInputDialog ( null,
          "Enter a value to calculate the factorial");
      value = Integer.parseInt(str);
      
      //For Loop to calculate the factorial
      facul = 1;
      for(int x=value; x >= 1; x--)  {

            if (value <= 1)
               value = 1;
               
            facul *= x;
               
      //show result
      JOptionPane.showMessageDialog( null, facul);
      
      //Stop program
      System.exit(0);
                     }

      }
}