Answer:
Following are the code to this question:
public class fact//defining class fact
{
public static void main(String[] ax) //defining main method
{
int x,f=1;//defining integer variable
System.out.println("Followig are the factorial from 1 to 10: "); //print message
for(x=1;x<=10;x++)//defining for loop to print factorial from 1 to 10
{
f = f*x;//calculating factorial and store value in f variable
System.out.println("Factorial of "+ x+" is: " +f);//print values
}
}
}
Output:
please find the attached file.
Step-by-step explanation:
In the above-given java program, a class "fact" is defined, inside the class main method is declared, in which two integer variable "x and f" is declared, in which the variable "f" holds an integer value that is "1".
In the next step, a for loop is declared, that uses the variable x to calculate the factorial from 1 to 10, and stores it value in f variable, in this loop a print method is used that prints its factorial value.