Write a Java-program to print Factorial Number using no return type with no parameterized method

Write a Java-program to print Factorial Number using no return type with no parameterized method

Program
import java.util.Scanner;
class Factorial
{
    void fact()
    {
        int x,n,f=1;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter n value : ");
        n=s.nextInt();
        for(x=1;x<=n;x++)
        {
            f=f*x;
        }
        System.out.println(f);
    }
}
public class Main
{
    public static void main(String args[])
    {
        Factorial ff=new Factorial();
        ff.fact();
    }
}

Output:

Enter n value : 5
120





More Questions


105 . Write a Java-program to print Factorial Number using no return type with no parameterized method
106 . Write a Java-program to print Factorial Number using no return type with parameterized method
107 . Write a Java-program to print Factorial Number using return type with no parameterized method
108 . Write a Java-program to print Factorial Number using return type with parameterized method
109 . Write a Java-program to print static method
110 . Write a Java-program to print static variable
111 . Write a Java-program to using static block
112 . Write a Java-program to print addition ,substraction ,multiplication,division using oops (using single class)
113 . Write a Java-program to print addition ,substraction ,multiplication,division using oops (using multiple classes)
114 . Write a Java-program to print Max Number program using no parametarized constructor with no return type with no parametarized method
115 . Write a Java-program to print Max Number program using no parametarized constructor with no return type with parametarized method