CS 101 - 11/29/11 Exam 2 in back (sort by last name) <== A-F G-L M-R T-Z ==> Count: 85 Min: 30 Max: 97 Ave: 64.28 Median: 65 St.Dev: 16.74 90's: 6 80's: 11 70's: 19 60's: 14 50's: 20 40's: 7 30's: 8 Next Time: Course Evaluations Lab This Week: Review for Final Exam Extra Credit in Blackboard Thursday: Project 4 is due ====================== Arrays: Looking at an array of integers int arrayName[]; A second way in which arrays can be specified: int[] array2; array2 = new int[10]; // allocated memory // for an array of // 10 integers // the following code allows the amount of // memory allocated to vary every time the // the code would be executed. int size; size = SimpleInput.getIntNumber ("Enter an int"); array2 = new int [size]; array2[3] = 7; ^ | Subscript Valid subscript range from 0 to Size-1 int i; for ( i = 0 ; i < 10 ; ++i ) { array2[i] = i * 2; } Pos: 0 1 2 3 4 5 6 7 8 9 Val: 0 2 4 6 8 10 12 14 16 18 // Sum the values in an array int sum = 0; int i; for ( i = 0 ; i < 10 ; ++i ) { sum = sum + array2[i] ; } System.out.println("The sum is: " + sum);