I feel like I'm really close... I'm supposed to have some other things configured and use JOptionPane... but I can't get the numbers to output correctly...
import javax.swing.JOptionPane;
public class M3_2E5 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//declare variables
final int MIN_VALUE = 0;
final int MAX_VALUE = 10;
int factorial = 0;
String response = null;
//show input box
response = JOptionPane.showInputDialog("Please enter a number between 0 and 10: ");
if (response == null){
JOptionPane.showMessageDialog(null, "You pressed Cancel.");
System.exit(0);
}
if (response.equals("")){
JOptionPane.showMessageDialog(null, "You didn't enter anything.");
System.exit(0);
}
factorial = Integer.parseInt(response);
if ((factorial < MIN_VALUE) || (factorial > MAX_VALUE)){
JOptionPane.showMessageDialog(null, "You entered an invalid number.");
System.exit(0);
}
if (factorial == 0){
JOptionPane.showMessageDialog(null, "The factorial of the number you entered is 1.");
System.exit(0);
}
for (int i = 1; i <= MAX_VALUE; i++)
{
factorial *= i;
JOptionPane.showMessageDialog(null, "The factorial of the number you entered is: " + factorial);
System.exit(0);
}
}
}
Thanks a bunch for anyone that helps!!!