Array

March 9, 2004

Today you will be creating two classes, one will be the driver and the other will hold your array and methods. In today's assignment you will be defining and initializing an array and writing several methods to manipulate the array. First: You have finished part one. Part two:
Write a method to print the array in reverse order.

Part three
Write a method to print out the second largest element in the array.

Part four
Write a method to print the average of the array.

Part five
Write a method to search the array for an integer the user gives you.

Part six (a little harder)
Create a histogram according to your array data
If you array looks like this 1,2,3,1,2,3,3,2,1,1
Your histogram would look like this:
 *
 **
 ***
 *
 **
 ***
 ***
 **
 *
 *

Part seven (they're getting harder):
Write a method to print the frequency of each integer in the array:
e.g.: If you array has the elements 2,3,2,4,2,4,2,5,4,5
You would print out:
  The number 2 is in the array 4 times
  The number 3 is in the array 1 times
  The number 4 is in the array 3 times
  The number 5 is in the array 2 times
Hint: you don't have to sort the array, use a second array.