Assignment-04b

 

 

 

Foreword

Resources

Code Listings

Foil Sets

Assignments

Solutions

External Resources

SiteMap

Search

Home

Up ] Assignment-01a ] Assignment-01b ] Assignment-01c ] Assignment-01d ] Assignment-02 ] Assignment-02a ] Assignment-03 ] Assignment-03a ] Assignment-03b ] Assignment-03c ] Assignment-03d ] Assignment-04 ] Assignment-04a ] [ Assignment-04b ] Assignment-05 ] Assignment-06 ] Assignment-07 ]

 

The goal of this assignment is to write an applet which uses a thread to display a population of data as it is produced. The data can be produced by the random number generator (or other method if suitable).

For example, suppose that the population is the sum of two randomly rolled dice. The population is produced by calling Math.random twice, mapping each random number to a face on the die (numbers 1 - 6) with a uniform distribution, i.e. it is equally likely that each face will be rolled. The data to be graphed is the frequency of each possible sum of two dice (numbers 2 - 12). The thread will have a loop - for each iteration of the loop, two dice are rolled and the resulting frequencies of all the sums of dice rolls so far are displayed. The display should be something like a bar chart or pie chart. Note that you may have to scale the data to fit nicely into the chart.

For your applet, you are to choose a data population, from your own experience or imagination. Generate the data by calling Math.random and using an appropriate distribution function to map the random number to a data point.

Then design a display of the data. In your applet area, you should have text describing the data population and the data itself. Using a bar chart or pie chart is fine, but you could also imagine that for some populations other types of displays would be good.

For example, suppose that your data population are the river otters living in each county of New York State. Each iteration of the thread will generate one more otter and assign it to a county, using a non-uniform distribution where most eastern counties have lots of otters (except for metropolitan New York) and western counties don't have very many. Then you could try to find an image which was a map of New York State showing the outline of the counties. At the beginning of the applet, the image would be downloaded. You could display the data by printing the frequency so far of river otters over each county on the map image.

Please try to pick your own unique data population and display it in an original manner. Points will be given for originality and creativity as well as for the correctness and documentation of the code.

The output of your applet will be a display of your data that changes over time as new data points are added. You should also add double buffering to your applet.

Finally, we note that it has not always been clear to some students how to write a description of their program. For this assignment, your description should answer the following questions:

What is your data population and its distribution?
How are you displaying the data and what java graphics techniques are you using to generate the display?