540 likes | 743 Views
Jeopardy. AP Computer Science edition Review 2. Arrays. Math. Printing / Comments. Vocabulary. Code. 100. 100. 100. 100. 100. 200. 200. 200. 200. 200. Jeopardy. 300. 300. 300. 300. 300. 400. 400. 400. 400. 400. 500. 500. 500. 500. 500. Define: Index. Arrays - 100.
E N D
Jeopardy AP Computer Science editionReview 2
Arrays Math Printing /Comments Vocabulary Code 100 100 100 100 100 200 200 200 200 200 Jeopardy 300 300 300 300 300 400 400 400 400 400 500 500 500 500 500
Define: Index Arrays - 100
Arrays - 200 Define: Element
The way to find out how many elements are in the array Arrays - 300
Write the code to copy the elements of array a into array b Arrays - 400
Write code to find the middle of array a and replace it with an asterisk “*” Arrays - 500
2 * 5 + 5 / 2 Math -100
2 % 5 + 5 / 2 Math - 200
Math – 300 (2 * 2 + 6) % 3
Math - 400 (7 + 2) * 5 + 1
Math - 500 4 + (2 + 5 * 3) % 2
int average = 93;System.out.println(“My average is ” + (double) average); Printing/Comments - 100
Printing/Comments - 200 System.out.println(“\tI like Apples\n A LOT!”);
Printing/Comments - 300 System.out.println(“\\*This is not\n a comment *\\”);
Printing/Comments - 400 System.out.println(“\\\n I am ready \n for break. \\\\ ”);
Printing/Comments - 500 System.out.println(“\\\“Happy \n Birthday!*\””);
Vocab - 100 Casting
Vocab - 200 Modulus
Vocab - 300 Concatenation
Vocab - 400 SNUL
Vocab - 500 Instantiation
Code -100 Zero out an array
Code - 200 Sum of an array
Code - 300 Average of an array
Code – 400 Minimum of an array
Sorts an array list in reverse order Code - 500
Define: Index Arrays – 100 (solution) The Index is the location of the element in the array. Other names for index are position and subscript.
Define: Element Arrays – 200 (solution) The Element is the actual item stored in a position in the array.
The way to find out how many elements are in the array Arrays – 300 (solution) arrayName.lengthwhere arrayName is the name of the array
Write the code to copy the elements of array a into array b Arrays – 400 (solution) for(int i=0; i<a.length; i++) { b[i] = a[i];}
Write code to find the middle of array a and replace it with an asterisk “*” Arrays – 500 (solution) a[a.length/2] = “*”;
2 * 5 + 5 / 2 Math - 100 (solution) 10 + 2 = 12
2 % 5 + 5 / 2 Math – 200 (solution) 2 + 2 = 4
(2 * 2 + 6) % 3 Math – 300 (solution) ( 4 + 6) % 3 ( 10 ) % 3 = 1
(7 + 2) * 5 + 1 Math – 400 (solution) 9 * 5 + 1 45 + 1 = 46
4 + (2 + 5 * 3) % 2 Math – 500 (solution) 4 + (2 + 15 ) % 2 4 + ( 17 ) % 2 4 + 1 = 5
int average = 93;System.out.println(“My average is ” + (double) average); Printing/Comments – 100 (solution) My average is 93.0
System.out.println(“\tI like Apples\n A LOT!”); Printing/Comments – 200 (solution) I like ApplesA LOT!
System.out.println(“\\*This is not\n a comment *\\”); Printing/Comments – 300 (solution) \*This is not a comment *\
System.out.println(“\\\n I am ready \n for break. \\\\ ”); Printing/Comments – 400 (solution) \ I am ready for break. \\
System.out.println(“\\\“Happy \n Birthday!*\””); Printing/Comments – 500 (solution) \”Happy Birthday!*”
Casting Vocab – 100 (solution) Casting is used to temporarily change data types:int score = (int) 83.4; yields 83double dScore = (double) 83; yields 83.0
Modulus Vocab – 200 (solution) Modulus is used to get the remainder when dividing 2 numbers. In Java, % is used:int rem = 9 % 2; yields 1
Concatenation Vocab – 300 (solution) Concatenation is used to combine strings together:String name = “John”;int grade = 87;String s = name + “ made a “ + grade;
SNUL Vocab – 400 (solution) SNUL is an acronym which is useful when sorting strings:Spaces / special charactersNumbersUppercase charactersLowercase charactersSpaces are lower than numbers, etc.
Instantiation Vocab – 500 (solution) Instantiation is used to create a new object:Student stu = new Student(“Tom”, 100);Robot karel = new Robot(1,1,West,0);
Zero out an array Code – 100 (solution) for(int i =0; i<a.length; i++) { a[ i ] = 0; }
Sum of an array Code – 200 (solution) int sum = 0;for(int i =0; i<a.length; i++) { sum += a[ i ]; }