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:**
Replace the sample code with the program shown above that draws two lines shown in Figure A.
Modify the program to add two more lines each connecting to the ends of the two existing lines.
[Diagram Description: Figure A depicts a rhombus shape with two horizontal arrows pointing inward from the left and right sides of the shape.]
Run the program to test.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc43e03e1-b353-4d50-a726-bab1a8232fef%2Ffdafca03-1001-4b86-b94e-c05e69d06e6f%2Fdz1j058_processed.png&w=3840&q=75)

Answer:
Explanation :
your code is running and this is giving correct result but some compiler gives error so we have change public class Factorial replaced with the public class Main in the line number 2 then this code running fine.
Some compiler error gives the due to this above reason
Step by step
Solved in 3 steps with 1 images









