L05 - Using Arrays
- Create a new class named
UsingArrays
.
- Using the lecture slides as a guide, declare and initialize an array of four integers that contains the values
3, 7, 13, and 18
.
- Using a for loop, display each of the four array values and the square of that value.
Sample Dialog
3 squared is 9
7 squared is 49
13 squared is 169
18 squared is 324
- Add a for loop and display each of the four array values. Also, if the value is less than 10, display the message
less than 10
. If the value is greater than 10 but less than 15, display greater than 10 and less than 15
. If the value is greater than 10, display greater than 15
.
Sample Dialog
3 is less than 10
7 is less than 10
13 is greater than 10 and less than 15
18 is greater than 15
- Write a program called
ArrayTest
that will do the following actions (complete each action before moving on to the next one):
- Create an array in the main method that contains the following integer values:
- Print out all of the array values using a for loop
- Find and print the array element with the maximum value
- Find and print the average value of the elements in the array
- Copy three elements from this array, starting at the second element, into a new array of size 3
No Comments