Question: Answer in Java To reinforce the use of strange and for loops. Assignment Write a program that reads in an integer greater than 1 in
To reinforce the use of "strange" and for loops. Assignment Write a program that reads in an integer greater than 1 in from the user. The program then computes and print out the factorial of the number read in. The factorial of a number is the product of all the natural numbers less than or equal to the number itself. That is the factorial of n is 1*2*3* ... (n - 2)*(n - 1)*n. Your program should stop if the user enters a negative number. Design You will probably want to make a class called Integer which has a single instance variable of class int. This class would also have an accessor method for the value and a method factorial, which will compute the factorial. This separates the input and output from the computation. Sample Output Enter a number: 5 The factorial of 5 is 120. Enter a number: 8 The factorial of 8 is 40320. Enter a number: 12 The factorial of 12 is 479001600. Enter a number: -1 Thank you and bye
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
