CS 4773 Object Oriented Programming, Spring 1998
Assignment 2

Due Thursday, January 29


This assignment has 3 parts but the third part is optional.
In this assignment you will write an applet to test the time resolution of the Java virtual machine.
Note that we are using Java 1.1 and you may not use any deprecated methods.
Turn in a copy of the source code for all parts of the assignment by the due date.


Part 1:
Make another copy of your applet from assignment 1 and call the new copy ShowTime1.java. Modify it as follows. Do not destroy the source code for any assignment you have done for this course until the course is over. Add a button to the applet called Start. Change the label on the text field to Number of Iterations. The message which displays the number should be updated when a new number is entered but the message which displays one hundred times the number should only be updated when the button is pushed.

Put a copy of the class file where it can be accessed from your course web page and put a link to it in your course web page. The link should be labeled Assignment 2, Part 1. Make sure you set the permissions so that anyone can access it from a browser.

Part 2:
Copy ShowTime1.java to ShowTime2.java and modify it as follows. The number to be entered should be an integer. The integer represents the number of iterations in a loop. If the value is n, then a push of the Start button causes n+1 calls to System.currentTimeMillis() to be put in consecutive entries in an array. The applet will then display various statistics about the n differences of consecutive values stored in the array. Instead of displaying one hundred times the number, display the following information on separate lines in the following order.

All of this display should be updated when the button is pushed. Since this might take up several lines, the message containing your name may need to be moved.

Note that there will be two lines which show the number entered. One is updated when the number is entered and the other is updated when the button is pushed.

The following parts of the assignment are optional:

As in Part 1, put a link called Assignment 2, Part 2 on your web page.

Part 3 (optional):
This part is for those with Java experience. Copy ShowTime2.java to ShowTime3.java and modify it as follows. Make the output look as neat as possible in a table with the numbers right-justified. All floating point values should be displayed with two places after the decimal point. Each time the button is pushed the information should be updated without any flickering of the display and without any residue from the previous display, even if the window size is increased. Here is where you can show off your skills. The best ones will be demonstrated in class.

Again, put this on the web with a link called Assignment 2, Part 3.