CSC 211

Spring, 2003

Assignment 6

Working with arrays

Due: 11:59pm, Wednesday, May 28th

Purpose: This assignment asks you to write a program that works with an array of integers.

Write a program called IntArray.java that performs the following steps:

  1. Prompts the user for the number of integers to be entered.
  2. Declares an array long enough to hold the values entered in the next step.
  3. Repeatedly prompts the user for integer values, placing each into succeeding positions of an integer array.
  4. Sorts the array.
  5. Displays the median value of the array.  The median of a sorted array of odd length is the value in the middle and the median of a sorted array of even length is the average of the two values in the middle.  For example, if the array has length 5 and contains the values 10 25 45 88 99, the median is 45.  If it has length 6 and contains the values 10 25 45 88 99 105, the median is the average of 45 and 87, which is 66.5.
  6. Computes and displays the product of the values in the array (that is, the result of multiplying together the elements in the array).  For example, if the array contains the values 8 10 11 13 15, this would return 171600 (which is 8*10*11*13*15).

What to submit: Through COL, submit the file IntArray.java.