// =========================================== // CMPU-181, Spring 2013 // Code from class // March 4, 2013 // =========================================== // Note: To use this code, save it in a file called MarchFourth.java // Then open it in drJava. class MarchFourth { // ========================================== // STATIC DATA -- class-oriented data // ========================================== static int x; static String str; static char c; static double dbl; // ========================================== // STATIC METHOD DEFINITIONS -- class-oriented functions // ========================================== // The FACTY function, defined below, is just like the Scheme // function of the same name, except that it belongs to the // MarchFourth class. // FACTY // ---------------------------------------- // INPUT: N, a non-negative integer // OUTPUT: The factorial of N. static int facty(int n) { if (n <= 1) return 1; else return n * facty(n-1); } }