Arrays as Parameters

Note:  Please keep the programs that you create today, in case you have a question about your grades for the ICEs at the end of the quarter. When you're working with a partner, each person should save his-or-her own copy.

## ICE 18.1: Passing Arrays To A Method; Processing Elements Of An Array

Use the provided ICE_18_PrintArray.java as a starting point and fill in the missing parts (in the PrintArray method, and in main, where it asks you to print the second array)

Create a method that will take an array of integers as a parameter, named PrintArray(). This method should simply print out every element of the array, one (1) number per line.

In main, create two (2) separate integer arrays:

• The first should be three (3) elements long, and hold the values {1, 3, 5}.
• The second should be five (5) elements long, and hold the numbers {1, 2, 3, 5, 7}.

HINT: There are extensive comments in the code that are there to point you in the right direction!

## ICE 18.2: Finding a Particular Value in an Array

Use the provided ICE_18_FindInArray.java as a starting point.

Building on the code from previous exercises, add the following to the end of your existing program:

your program should, after doing everything else, ask the user for a number to look for in the array.

Then it should go through the array, and if it finds that value in the array, it should print out a message telling the user what the index (slot number) is where that value is stored.

It is recommended that you start by creating this functionality down in main and getting everything to work (using the shortArray or longArray there).

Once that's working you should create a separate method called Find() which will be given the value to look for, and will print out the message if the value is found in the array (make sure to change your array names from shortArray or longArray to whatever the placeholder array name you used as the passing array parameter)

In ICE_18_FindInArray.java, fill in the missing code in the Find method.

HINT: There are extensive comments in the code that are there to point you in the right direction!

When you get done with this exercise, show your Instructor, then go on to the next section.

## ICE 18.3: Finding a Maximum Value in the Array

Use the provided ICE_18_FindMaxInArray.java as a starting point.

Building on the code from previous exercises, add the following to the end of your existing program:

your program should, after doing everything else, go through the array, and figure out which number is the largest number in the array. It should print out that number, along with the slot number where that value is stored.

For this exercise you should do all the work down in the main method.

Use the provided ICE_18_FindMaxInArray.java and fill in the missing parts (you can also use code and methods from from the prior ICE).

HINT: There are extensive comments in the code that are there to point you in the right direction!

When you get done with this exercise, show your Instructor, then go on to the next section.

## ICE 18.4: Finding a Maximum Value in the Array, with Methods

Use the ICE_18_FindMaxInArray.java that you had worked on previously to change the action from main to a separate method in the ArrayHelper class called FindMaxInArray.

Create a method that will be given an array of integers. This method should find the largest number stored in the array, and it should print out that number, along with the slot number where that value is stored.

HINT: There are extensive comments in the code that are there to point you in the right direction!

When you get done with this exercise, show your Instructor.