Chandler-Gilbert Community College Spring 2005
Statistics array assignment

Home
Schedule
Instructor
Links
Syllabus

  1. We're doing arrays instead of monsters.  However, arrays can be a lot like monsters.
  2. Examine how the program should work:
    Demo of statistics array used for grades
  3. I have written the user interface class for you.
    StatsArrayController.java
    Review the controller to get an idea of how it's set up.
  4. The design for the StatsArray class is
  5. StatsArray
    Know:
    an int array named stats (user specifies size)
    x, y location where array is displayed in paint area (user specifies location)
    Do:
    fill the int array with random data
    display the contents of the array
    find and return largest value
    find and return smallest value
    find and return sum of all values in the array
    find and return the mean of all values in the array
    Count the number of int values in the array which are >= 90
    If the array contains an 80, return the index number of the first 80 otherwise return a -1
    sort the array
  6. Create StatsArray.java.  
    Create instance variables for the things a StatsArray will know.
  7. Write a constructor method which will store the x and y coordinates provided by the user in the instance variables and will instantiate the array object based on the user-provided array size.
  8. Create empty methods for each thing a StatsArray can do.
    For methods that don't return values:
    public void methodName() {
    }
    For methods that DO return values:
    public datatype methodName() {
        datatype ans;
        return ans;
    }
  9. Write the fill array method
  10. Write the display array method (we should get this far in class)
  11. Write any of the remaining methods you can do EXCEPT sort.  Because you are working with arrays, each method will need at least one for loop.  (These methods are like small puzzles.  If you can't figure out how to do one, move on to another.)
  12. challenge: teach this array to do a trick or two in addition to those already included in the design.
 

Home ] Up ] Instructor ] Links ] Syllabus ]

date last modified: 04/05/04
copyright 2005 Greg Swan