Lab Assignment 2
CS202, Summer 2006

Please upload your source code files using CSNS. Note that file uploading will be disabled automatically after the lab ends, so please turn in your work on time.

1. (5pt) Write a Java program Tribonacci.java that reads an integer n from console input and outputs the nth Tribonacci number t(n). The nth Tribonacci number is defined by the following equations:

t(0) = 1
t(1) = 1
t(2) = 1
t(n) = t(n-1) + t(n-2) + t(n-3) for n >2

2.(10pt)  Implement a recursive method that sorts a given array into ascending order. Write a Java program to test your method.

3.(5pt) [Lab Manual (Chapter 3)] p5. Matching. For this exercise, turn in a text file lab2.txt where the answers are in the following format:

1. g
2. c
...

4. (5pt) [Lab Manual (Chapter 8)] p35. Complex Numbers.

5.  [Lab Manual (Chapter 8)] p47. Programming Challenge 1. Rectangle Class.