Hey guys,
I've just picked up a course at uni dealing with OO programming using Java..
I have a really basic question here that.. while the logic could be done by a sleeping child, I'm not entirely sure of the syntax that comes about from using classes..
Any chance someone could give me a shove in the right direction here? I'd be tempted to chuck the factorial algorithm straight into the above class and print it out instead of printing the arg's, but I think the point of it is to not do that..
Thanks in advance guys.
I've just picked up a course at uni dealing with OO programming using Java..
I have a really basic question here that.. while the logic could be done by a sleeping child, I'm not entirely sure of the syntax that comes about from using classes..
The purpose of this class is to print out the arguments entered at the command line.Code:public class Arguments { public static void main(String[] args) { if (args.length > 0) { for (int i = 0; i < args.length; i++) { System.out.println("args[" + i + "]: " + args[i]); } } else { System.out.println("No arguments."); } } }
Write a Java application to calculate the factorial of an integer n, using iteration (not recursion). The factorial function n! is given as
0! = 1
n! = n * (n - 1) !
The input value is given as a command line argument to the Java application. Write a FactorialDemo class based on the Arguments class above to call the Factorial Class and accept the input value(s) from the command line.
Any chance someone could give me a shove in the right direction here? I'd be tempted to chuck the factorial algorithm straight into the above class and print it out instead of printing the arg's, but I think the point of it is to not do that..
Thanks in advance guys.