/* FILE NAME: FirstApp.java * AUTHOR: Stella * DATE: Oct 18 2007 * COMMENTS: Creates a class, to define a class method to perform some computations. * It takes its input from the command line. * It is intended as a first example on java applications. * * To use it: * Type: * > java FirstApp x * * in the command line ("Interactions pane, in DrJava), * where x is an integer. * MODIFICATION HISTORY: */ public class FirstApp { public static int boo (int n) { if (n<=2) { return n; } else { return n + boo(n/2) + boo(n/3); } } //It calls the class metod boo() and prints out the result. //It takes its input from the keyboard. public static void main(String[] args) { int number = Integer.parseInt(args[0]); int result = boo(number); System.out.println("boo(" + number + ") = " + result); } }