Lab 11: Array Example (Extra Credit)

Overview

This week, you're you're writing an applet that does the following: generates an array of numbers, then finds three statistics about those numbers: minimum, maximum, and average. You will use a RandomIntGenerator to fill the array with random integers, but you'll also give the user control over the size of the array and the lowest and highest numbers the RandomIntGenerator is allowed to produce.

Using the awb classes

We have created some extra classes for you to use to make your life a bit easier. In particular, you gain the use of DoubleFields and IntFields. To use these classes, you should have run the setclasspath command in lab 7 to use the awb classes.

Writing the Applet

You'll need to refer to both your lecture notes and your previous labs to get information on how to write this one. Here's an outline of the steps you'll need to take. Take some time to work through the problems before you consult a TA. The rough spots are in there intentionally.


Make your ArrayExample.html page to display the applet, and test it out until it meets the above specifications. In order to use the awb classes, you must specify that in your HTML code as follows:

<applet code="ArrayExample.class" archive="awb.jar" width="500" height="500"> </applet>

The interesting things about this applet are the summary statistics, of course - the user can play with the size and bounds of the array, and see how big it has to get before the average becomes identical to the median of the two boundaries, and before the min and max become identical to the boundaries. You can receive extra points for putting some text above your applet explaining this phenomenon.

If you do not finish in lab, you should submit your files as usual.

submit_cps001 lab11/secA ArrayExample.java ArrayExample.html
where A is your lab section number.