## 1 Sample Code Declare an int array of length 3. Use a for loop to prompt for 3 numbers and enter them into the array. Print out the array. ```java int [] numbers = new int[3]; Scanner scan = new Scanner(System.in); for (int i = 0; i<numbers.length;i++) { System.out.println("Enter a number"); int n = scan.nextInt(); numbers [i] = n; } System.out.println("... and your numbers are... "); for (int i =0; i<numbers.length; i++) { System.out.println(numbers[i]); } ``` ## 2 Exercises 1. Print out the elements of the following array: int \[\] numbers = {1,2,3,4,5}; 2. Declare and initialize a String array containing the days of the week. Print out a random day. 3. Output the sum of the elements in this array: int \[\] values = {3,5,4,7,2,3}; 4. Output the average of the elements in this array: int \[\] values = {3,4,5,6}; 5. Declare an int array of length 5. Use a for loop to prompt for 5 numbers and enter them into the array. Print out the array. 6. Declare an int array of length 4. Use a for loop to prompt for 4 numbers and enter them into the array. Print out the average of the four numbers 7. The following code will convert a String s to an array of characters c. Print out the characters: String s = "This is a string"; char \[\] c = s.toCharArray(); 8. Use what you learned in the last question to count the number of times the letter e occurs in the String "I never saw a purple cow"