Question
Problem description:I n Java Write a program that takes a positive integer from user (use JOptionPane class for both input and output). The program outputs
Problem description:I n Java 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. Note: 1) You dont 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started