Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

Programming Challenge 5: Three List Statistics Interpreters

Your task is to write three separate Java programs for this assignment, all pertaining to the storage, manipulation, and use of lists. The first two will feature arrays. The last one will feature an ArrayList object.

Why do it?

By engaging in this programming challenge you will have an opportunity to do some array processing and some ArrayList processing, you will engage in working by analogy, and you will gain additional experience writing interpreters.

The Entrance

Review the given program, the ArrayStats program of the arrayplay package. Read and understand it!

Problem 1: The ArrayStats program of the arrayplay package.

  1. Enter the given program in your Java/IntelliJ world.
  2. Create a data file of numbers called NumberSet.txt containing between 10 and 15 integers of your own choosing. Place the file in a directory called public_html/data inside your home directory.
  3. Run the program, and interact with it in much the same manner as we did in the example demo.
  4. Add the following pieces of functionality to your program, working by analogy with what is there and being sure to update the help command as necessary:
    • Max: Add a command to compute the maximum element in the list and display it. Remember that like the minimum, the list must be sorted first.
    • Average: Add a command the compute the average of the elements in the list and to display it. Take careful note of the fact that our list is full of integer values, and the average is unlikely to be an integer value!
    • Median: Add a command to find the median and return it. You may wish to refresh yourself on how to compute the median!

Problem 2: The DoubleArrayStats program of the arrayplay package.

  1. By analogy with the ArrayStats program, write a program called DoubleArrayStats to store and manipulate doubles (instead of ints) in an array. Do so within the arrayplay package.
  2. Create a data file of doubles called DoubleSet.txt containing between 10 and 15 doubles of your own choosing. Place the file in a directory called public_html/data inside your home directory.
  3. Run the program, and interact with it in a manner analogous to the integer demo.

Problem 3: The DoubleArrayListStats program of the arraylistplay package.

  1. By analogy with the DoubleArrayStats program that you just wrote in the arrayplay package, write a program called DoubleArrayListStats in the arraylistplay package which features an ArrayList object rather than the array object. In doing so, be thinking about whether there is an easier way to do a task with ArrayLists! There are likely some unnecessary pieces of functionality in the program given the translation to ArrayLists!
  2. Run the program, and interact with it in a manner analogous to the array-based demo.

The Exit

  1. The assignment is due Tuesday, November 14th.
  2. Please post your work to you work site. You must post it to your web site to get credit.
  3. Think for a little while about this assignment and your engagement with it. What did you learn that is conceptually significant? What did you learn that is technologically useful? What is your most salient thought about the assignment and your engagement with it?

Featured Demo

Featured Program