The day after these are assigned we will cover solutions in class. After that, I will post the solutions online.


  1. Creating an AddressBook Classes Using the Human class covered in the Language Basics notes, let's build an address book. Notice that it already behaves like an address book, only we can't store addresses or emails.

    Your task is to do the following...
    1. Create a new project in Eclipse called "AddressBook"
    2. Add a new Java class to your project called "AddressBook"
    3. Copy the file "" from the Language Basics example that file.
    4. Change the name of the Test class to "AddressBook"
    5. Modify the Human class to have properties and associated methods for address and email, of appropriate types.
    6. Add a label and input for entering the address.
    7. Add a label and input for entering the email.
    8. When the user fills out the form to enter a new contact (include name, birthdate, beard length, and now address and email), and click "Add Contact", be sure to set the address property of the Contact object and have the display also include the address of all contacts.
    Install Java plugin to view this applet.

  2. Using a method for the Powers Assignment Recall from the first assignment that you had to write a program to compute baseexponent for a user provided base and exponent.

    What you must now do is re-write that assignment, only you will defined a method to compute the power.

    Specifically, do the following:
    1. Create a new project in Eclipse called "PowersWithAMethod"
    2. Add a new Java class "PowersWithAMethod"
    3. Copy the code from your old Powers assignment into this one.
    4. Add a method to your file with the following definiton:
                     int  power( int base, int exponent ) {
    5. Put all of your code to compute the power into that method.
    6. Now, use this method in your actionPerformed method to compute and display the power.
    7. Your new applet should look and work identically to your old one
    Install Java plugin to view this applet.

  3. A Big One: Recursion! The Fibonacci numbers are a sequence of integers where the 1st and 2nd numbers in sequence are both 1 and each of the remaining numbers in the sequence is the sum of the previous two. Expressed mathematically this is:
          ƒ(1) = 1
          ƒ(2) = 1
          ƒ(i) = ƒ(i-1) + ƒ(i-2)
    Write a program to find the nth Fibonacci number.

    Specifically, you should:
    1. Create a new project in Eclipse called "Fibonacci"
    2. Create a new Java class called "Fibonacci"
    3. Use the sample code from the Generic program we covered yesterday.
    4. Modify it to the following: Change the label to say "N: ".
    5. Modify the button to say "Compute Nth Fibonnaci Number"
    6. Add a method to your class with the following method...
                     int fibonacci(int n) {
                           // here's where you have to add some code!
                           // specifically, you want to return the nth Fibonacci number
    7. When the user clicks the button, display the following in the output/textarea:
      "The Xth Fibonacci number is Y"
      where X is the number the user entered and Y is the Xth Fibonacci number.
    Install Java plugin to view this applet.