W10 Homework Assignment

1) Complete the last two methods of the partially-implemented program below - note that this main class contains two methods besides main(), which we'll discuss during W10. Submit your .java file W10 Homework via webCT before the beginning of lab  (see the webCT deadline). You will be required to demo your program during lab.


/**
 * @author hornick
 * This class/program creates arrays, fills them with values, and computes the averages of the values
 */
public class CollectionApp {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		double numArray[] = null; // a primitive array that holds a collection of doubles

		System.out.println("Enter a low and a high value: ");
		Scanner kbd = new Scanner(System.in);
		int low = kbd.nextInt();
		int high = kbd.nextInt();
		
		numArray = fillArray( low, high ); // create and fill the array
		
		double avg = getArrayAvg( numArray );
		
		System.out.println("Array avg = " + avg  );
	}
	
	/**
	 * This method allocates and fills an array with the values from the specified low to the specified high;
         * for example, if low is -1 and high is 3, then the array will hold -1, 0, 1, 2, 3
	 * @param low - the lowest value in the array
	 * @param high - the highest value in the array
	 * @return - reference to the created non-empty array of doubles
	 */
	public static double[] fillArray( int low, int high ) {
		// put your additional code here that allocates and fills the array
		
		// return the reference to the new array
	}
	
	
	/**
	 * This method computes the average of the values in the specified array
	 * @param numArray - reference to an array of values, created elsewhere
	 * @return - the average of the values within the array
	 */
	public static double getArrayAvg( double numArray[] ) {
		// put your additional code here that computes and returns the average
	}
}