$29
Introduction
As we discussed in lecture, arrays can be very useful data structures. We already discussed how to load items into an array and how to search an array for an item. In this lab, you will implement a number of other useful operations that can be done on arrays. You will then write a simple main program to utilize your methods. For help with this lab, see slides and ex11.java.
Lab Exercise
You are to write the program named Lab06.java that contains the following four static methods:
public static double max(double[] data) that returns the maximum value in the array data (2 points)
public static double min(double[] data) that returns the minimum value in the array data (2 points)
public static double sum(double[] data) that sums all items in the array and return the result (2 points), and
public static double ave(double[] data) that call the sum() method and then return the average. (2 points)
Once you have completed the methods above, write a simple main program (2 points) that does the following:
1. Asks the user how many items will be entered
2. Creates an array of double of the correct size
3. Prompts the user and reads in the values
4. Calculates and prints out the max, min, sum, and average using the methods above.
Due Date and Submission
Once you completed the program, you must demonstrate your program for your Lab TA. Once your TA already checked you, DO NOT FORGET to submit your Lab06.java le to the CourseWeb under this lab by the due date.
If you do not complete the lab this week, you may nish it and submit your code to the CourseWeb before the due date. However, you need to demonstrate it to your TA at the beginning of next week’s lab.
No late submission will be accepted.
CS/COE 0401 | Intermediate Programming with Java Page 1