CSE 341 -- Programming Languages

Autumn 2001

Department of Computer Science and Engineering, University of Washington

Steve Tanimoto (instructor)

Assignment 5

Version 1.0 of November 16 (Subject to Change)

A Sip* of Java 

Due date and time: Wednesday, November 21, 2001 (at the beginning of class).

Turn in this assignment by putting all your files in a subdirectory of your cubist www directory, named a5. You should have a web page (containing your applets) named index.html in that directory.


 

Title: A Sip* of Java

Purposes: 1. Learn about how Java handles class structure, inheritance, component accessibility and various other language issues. 2. Gain practice creating applets.

Instructions: Read Chapters 1-9 of Learning Java.
 
Part A: Applications
1. (Simple, imperative coding in Java.) Write a Java application that prints out the first 50 Fibonnaci numbers.
 
2. (Working with inheritance and info hiding) Write a Java application that constructs several instances of 3-D figures as software objects and prints out their descriptions by invoking their describe methods. Use the following guidelines:

Part B: Applets
3. (Basic applet structure) Write a Java applet that determines the nth fibonnaci number by letting the user enter an integer (n) in a text field and then click on a button labeled Nth Fib.No. It should then draw the number on a drawing area (such as a JPanel or a Canvas) under the text field and button. Put the applet on a web page and turn in both a URL to the web page and hardcopy of your code. You can put the web page in your Cubist account, in your www subdirectory.
Optional variation 1: instead of returning the Nth Fibonnaci number, return the nth Prime number. In this case your button should be labeled Nth Prime.
Optional variation 2: return not a number but a string that spells the number out in English words. For example, if the user enters 365 and clicks the button (labeled "to English words"), it should display "three hundred sixty-five". You should handle numbers up to 999,999.
 
4. (Applets and Inheritance) Choose one of the following two options.

* "Sip of Java" -- All right, perhaps we should have called this "A Single Short Latte."

Group Work:  This assignment should be performed individually (not in groups).