Write the Java class Basic with the following
public, static methods:
int sum_of_squares(int x, int y)
int fact(int n)
int fib(int n)
int num_reverse(int n)
%' operator (remainder) and/or the `/'
operator (integer division). If you do define a ``helper'' method,
it should be static and should not be
public. You may assume n is non-negative.
If the following java program (in the file Test.java)
were compiled:
abstract class Test {
public static void main(String[] args) {
System.out.println(Basic.sum_of_squares(3, 4));
System.out.println(Basic.fact(5));
System.out.println(Basic.fib(8));
System.out.println(Basic.num_reverse(8675309));
}
}
The results of
java Test
would be
25 120 21 9035768
Write your answers to the exercises in a file (with comments, following the proper indentation rules, whatever they may be for Java), and send that file to
c311@lakshmi.cs.indiana.eduwith the subject line
13Assuming you've saved your homework in the file ``asgn.ss'' in the current directory, one way to submit is with the command:
Mail -s "13" c311@lakshmi.cs.indiana.edu < asgn.ss
The ``grader'' program will not test your submission, it will only
confirm the receipt of the submission and save it.
Back to the c311 page
ehilsdal@cs.indiana.edu