I am really new to
java programming. I thought i would begin with a factorial generating program with the input taken from the keyboard.
The program is compiling well and is running too but the output is always 0.
There seems to be something major which i am missing out. kindly help me.
The code is as follows:
import java.io.*;
class fact
{
public static void main(
String []a)
{
int i=0,temp=1,j=1;
BufferedInputStream q= new BufferedInputStream(System.in);
try
{
System.out.println("Enter the no. whose factorial is to be found.....");
i=q.read();
q.close();
}
catch (Exception e)
{
System.out.println("Exception ecountered");
}
for(j=1;j<=i;j++)
temp=temp*j;
System.out.println("\n\n\nThe factorial of the no. is \t"+temp);
}
}