Arrays As Return Values

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: Filling An Array With User Input: Processing All Elements Of An Array

            Download the file named ParamReturnValuePractice.java, and fill in the ??? with return value & parameters for each of the given methods.  Only AFTER you've set up return values & parameters for ALL the methods should you go back & start filling them in.  Be prepared to explain why you made the choices you did, and why those choices are better than any alternatives.

Part 2: Filling An Array With User Input: Processing All Elements Of An Array

 

            Create a method that will return an array of integers named FillArray.  This method should start by asking the user how many integers the user wants to type in, and then create an array big enough to hold all those numbers.  Then the method (service) should ask the user for that many numbers, storing one response in each slot.  Lastly, the method should return the array to the caller.

            In main, call this new method, and save the response using a local variable.  Then pass the array that you got from FillArray to PrintArray.

            Use the provided ICE_18_FillArray.java as a starting point (this file was provided in a prior set of exercises), and fill in the missing parts (in the FillArray method).  Notice that main calls the PrintArray method that you created in the prior part of these ICEs – you should copy that method into the ArrayBot class that's here.

 

Part 3: 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).

 

Part  4: Practice Using Arrays: Processing All Elements Of An Array

 

Create an array of doubles that has space enough for five separate values.  Write a while loop that will set the value of the first 5 elements of your array to the numbers 5 through 10.  Then write a for loop that will print out the first 5 elements of your array.