I need help editing this code I keep getting an error import java.util.Scanner; public class Factorial { public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.print("Enter a number to find its factorial value : "); //read an integer value from keboard int num=Integer.parseInt(scan.nextLine()); //Calling fact method System.out.printf("Facorial of %d is %d ", num,fact(num)); } /*Recursive method, fact * Method name:fact * Input arguments:n as integer * Output arguments: an integer value * */ public static int fact(int n) { //Base case : //Return 1 if n value is either 0 or 1 if(n==0 || n==1) return 1; else //calling method, fact with n-1 return n*fact(n-1); }// }//
I need help editing this code I keep getting an error
import java.util.Scanner;
public class Factorial
{
public static void main(String[] args)
{
Scanner scan=new Scanner(System.in);
System.out.print("Enter a number to find its factorial value : ");
//read an integer value from keboard
int num=Integer.parseInt(scan.nextLine());
//Calling fact method
System.out.printf("Facorial of %d is %d ", num,fact(num));
}
/*Recursive method, fact
* Method name:fact
* Input arguments:n as integer
* Output arguments: an integer value
* */
public static int fact(int n)
{
//Base case :
//Return 1 if n value is either 0 or 1
if(n==0 || n==1)
return 1;
else
//calling method, fact with n-1
return n*fact(n-1);
}//
}//
![ASSIGNMENT:
Write a program to use the capability of Recursion to calculate factorials.
For example, 5 factorial is normally written as 5!
5! = 5*4*3*2*1
5! = 120
Use recursive function calling to multiply.
5*4*3*2*1
And then print the result.
120
Your output should resemble the image below.
>sh -c jav
d. -type f
> java -cla
5
4
2
5! = 120
}
Note:
5! is use in this example but your program should calculate the
factorial for any number entered.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc43e03e1-b353-4d50-a726-bab1a8232fef%2Fe23677aa-8676-4421-9f93-211a2321fc08%2F3mh4ybb_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)