Lab Assignment 7
CS201, Spring 2004


1. [D&D] Ex 6.7. This exercise will not be graded.

2. [D&D] (5pt) Ex 6.13(b). First of all, you don't have to use a single statement, e.g. using multiple statements or a method is acceptable. Secondly, write a complete program to test your statement(s). In particular, use a while or a for loop in your test program, output the random number at least 20 or 30 times and observe the output.

3. [D&D] (5pt) Ex 6.28 and  6.40. Name the non-recursive version of the GCD method gcd1, and the recursive version gcd2. Instead of writing a Java applet, include both methods in a Java application and test them properly.

4. [D&D] Ex 6.39. Note that not only you need to add some output statements, you may also need to add extra parameter(s) to the method. The following is a sample output when calculating the fourth number in the Fibonacci series.

fibo(4)
    fibo(3)
        fibo(2)
                fibo(1)
                fibo(0)
        fibo(1)
    fibo(2)
        fibo(1)
        fibo(0)
fibo(4) is 3