need help in this program

I was programming for finding the factorial of an input number but stuck on the underlined portion,please help

class fact

{

public static void main(String []args)

{

int a=Integer.parseInt(args[0]);

int b,d;

int c=0;

if(a>0)

{

b=(a-1)*a;

d=b+c;

a--;

System.out.println("Factorial is="+c);

}

else

{

System.out.println("No Factorial");

}

}}

[468 byte] By [duke277a] at [2007-11-26 17:08:14]
# 1
What happens? What are you expecting to happen? How are you stuck?
DavidKNa at 2007-7-8 23:36:04 > top of Java-index,Java Essentials,Java Programming...
# 2
Stuck on assigning d to the value of (b + c)? How so?I bet your real "question" is "Will you do my homework for me?" right?
warnerjaa at 2007-7-8 23:36:04 > top of Java-index,Java Essentials,Java Programming...
# 3
actually i m stuck in that IF ELSE loop,at d=b+c; portionwhat should i write there to make the program work for finding factorial of the input number?
duke277a at 2007-7-8 23:36:04 > top of Java-index,Java Essentials,Java Programming...
# 4
@ warnerja, sorry but you are absolutely thinking wrong,actually I got this question today in my class quiz & now I m trying to explore how it runs,thatsall.
duke277a at 2007-7-8 23:36:04 > top of Java-index,Java Essentials,Java Programming...
# 5
For a start you'd probably be better off renaming your variables - the ones you have there are pretty meaningless and they might be standing in the way of you actually understanding what you're doing.
DavidKNa at 2007-7-8 23:36:04 > top of Java-index,Java Essentials,Java Programming...
# 6

duke277,

Your code is a long way from being able to do the correct computation of factorial. For example, you display "Factorial is="+c, but the only value ever assigned to c is 0. You could have discussions in this forum with members as they try to teach you how to compute a factorial, but I really think the best thing for you to do is sit down with your instructor or a teaching assistent, etc... and work through this together. it may be worth it to find someone at your campus who can tutor you. This is not meant to be derogatory, but based on your previous posts, which have been legion, you're flailing around -- your code is often far from correct, and the suggestions and hints given to you in this forum don't seem to be enough for you to correct your own code. Again, tutoring or going to your instructor's office hours would be your best bet.

Laszlo

DrLaszloJamfa at 2007-7-8 23:36:04 > top of Java-index,Java Essentials,Java Programming...