InClassExercise18

InClassExercise18 - and print out the results. 7. Exercise...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS112: In-class Exercise 18 More with ArrayLists. 1. Copy the InClass18 folder from the usual locations. 2. Open the project using BlueJ. 3. Edit the source file for InClass18 . 4. Note that this already contains a testRun and a max method. 5. Note that ArrayList< type > requires that type be of an object type and not a primitive type. So for integers, you must use the class type Integer , and not int . For example, ArrayList<Integer> arrayOfIntegers; 6. The testRun() method is used to test the max method. Note how the testRun() method declares, instantiates, and adds integers to an array so that we can invoke max on the array
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: and print out the results. 7. Exercise A. Program a min(ArrayList&lt;Integer&gt; a) method that will return an int that is the minimum of the integers in the array. Modify the testRun() so as to test this new method. Invoke the testRun() method for testing. 8. Exercise B. Program a average(ArrayList&lt;Integer&gt; a) method that will return a double that is the average of the integers in the array. Be careful with dividing two integers if you do not wish the result to be rounded down. Modify the testRun() so as to test this new method. Invoke the testRun() method for testing....
View Full Document

This lab report was uploaded on 04/08/2008 for the course CSCI 112 taught by Professor Yuen during the Fall '07 term at Lake Forest.

Ask a homework question - tutors are online