A. Introduction
Suppose you are in a large high school and there are 300 students in your class. Even though each of you know your own height, the school administration wants to know the average height of this class and the tallest student.
Similarly, sometimes you might want to find out the average price of all 5-seat SUVs, as well as the most expensive or inexpensive one etc.
This type of problems involves handling a relatively large amount of values in your program. You can not create individual variables to store them. What to do?
B. Watch how to create an array ... ( Slides )
C. Now, please try the following in your IDE and save your project for the following sessions.
Create a double array of 10-30 elements, name it height.
Is there another way to declare an array? If you print out height[0], what value will be printed? what value is height[2] or height[299]? height[300] ? Try to print all of these and explain why you get what you see.
D. Program
Declare, create and initialize an int, a double, and a String array, each with 10-30 elements.
Find the sum of the int array.
Find the average of the double array.
Does your String array contains the word "Hello"? Write code to find out.
How do you find the maximum and/or minimum value of the int or double array?
Can you create an array with varied length?
How do you copy an array?