Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions