This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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:
public static void main(String a)
BufferedInputStream q= new BufferedInputStream(System.in);
System.out.println("Enter the no. whose factorial is to be found.....");
catch (Exception e)
System.out.println("\n\n\nThe factorial of the no. is \t"+temp);
Lalit Bhatt wrote:Also try to use ide and use the debugging features. You can see a tutorial on eclipse id here
Disagree. If you are a beginner, it is more likely that the many features of an IDE will confuse you. Learn Java from the command line, then use an IDE (I think Eclipse is a very good tool) once you are familiar with Java.
And welcome to JavaRanch
That is a possible way to calculate a factorial, but I challenge you to do it the way the mathematicians would, where you return 1 when the input is 0. Also find out what the largest argument that method will take before giving an error because of arithmetic overflow.