Arrays as parameters

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

 

Part  1: Passing Arrays To A Method; Processing All Elements Of An 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, 1 number per line.  In main, create two integer arrays.  The first should be 3 elements long, and hold the values {1, 3, 5}.  The second should be 5 elements long, and hold the numbers {1, 2, 3, 5, 7}. 

            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 is asks you to print the second array)

 

Part  2: Finding a particular value in an array

            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 inside main and getting everything to work.  Once that's working you should create a separate command (called Find) which will be given both the array and the value to look for, and will print out the message if the value is found in the array.

            Use the provided ICE_18_FindInArray.java as a starting point, and fill in the missing code in the Find method.

 

Part  3: Finding a maximum value in an array

            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 in the main command.

            Use the provided ICE_18_FindMaxInArray.java as a starting point, and fill in the missing parts (in the FindMaxInArray method, and the PrintArray method from the prior ICE).

Part  4: Finding a maximum value in an array: With Methods

            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.

            Use the provided ICE_18_FindMaxInArray.java as a starting point, and fill in the missing parts (in the FindMaxInArray method, and the PrintArray method from the prior ICE).