Write a program that takes a positive integer from user (use JOptionPane class for both input and output). The program outputs the factorial of that integer. The factorial of the integer n is n * (n-1) * (n-2) * … * 3 * 2 * 1. For instance, the factorial of 4 is 4 * 3 * 2 * 1 = 24.
Your program should allow the user to continue entering different integers for the calculation until -1 is entered. Write the prompt clearly.
1) You don’t need to handle the wrong input type such as a string. But for any negative integer except -1, you should allow the user to re-enter the input.
2) Must use a ‘for’ loop to calculate the factorial.
3) This program needs nested loops. The outer loop controls the entering input data (positive integer: output the factorial and prompt user for another input; -1: finish the program; other negative integer: prompt user to enter a correct input). The inner ‘for’ loop calculates the factorial of each input data.
thank you greatly appreciate it compile and ran perfectly
the first joptionpane while loops works perfectly.
only issue is getting the second joptionpane "please enter a positive number" to come up
and the when i enter a number to be factor i get a 10 number for example 24 comes out to -7759462002