thanks a lot for your help everyone! I finally figured out my program!
package proj3;
import javax.swing.*;
import java.text.*;
public class factorial {
public static void main(String[] args) {
String s1;
int num1,total;
num1=0;
total=1;
s1=JOptionPane.showInputDialog("Enter a number to calculate its factorial.\nEnter -999 to exit the program");
num1=Integer.parseInt(s1);
while(num1!=-999)
{//start while loop 1
System.out.print(num1 + "!=");
while ((num1 > 1) && (num1 != -999))
{ //start of while statement 2
System.out.print(num1 + "*");
total = (total * num1);
num1--;
} //end of while statement 2
System.out.print("1=");
System.out.println(total);
System.exit(0);
}//end while loop 1
}
}