daniel_lawson9999

Daniel Lawson Java Chapter 17 self check 7.1/2 evens

Oct 4th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. Daniel Lawson 10/4/2016
  2.  
  3. 2.
  4. numbers[0] first element , numbers[9] last element if it is 10 long,numbers[numbers.length-1] last element no matter the length
  5. 4.
  6. int max = 38;
  7. int min = -7;
  8. int[] odd = new int[Math.abs(max - min+2)/2 ];
  9. for(int i = 0;i<odd.length;i++){
  10.     odd[i] = min + i*2;
  11. }
  12. System.out.println(Arrays.toString(odd));
  13. 6.
  14.  
  15. 0 = 3,    1 = 3, 2    3     4 = 6,    5 = 9     6       7 = -18,    the array = [3,3,0,0,6,9,0,-18]
  16.  
  17. 8.
  18.  a. int[] a = {17,-3,42,5,9,28};
  19.  
  20. 10.
  21. public static int max(int[] array){
  22.  int max = 0;
  23.  for(int i = 0;i<array.length;i++){
  24.     if(array[i] > max)max = array[i];
  25.  }
  26.  return max;
  27. }
  28. 12.
  29. traversing an arrary is manipulating an array using for loops , an example of this is the max method created in the last problem.
  30. 14.
  31. the arrary contains 3, 24, 8, -5, 6, 1
  32. 16.
  33. for count change the int[] list into String[] list ,change target to a char,  and then have another for loop inside hte for each loop saying for(int i = 0; i < list[n].length();i++) if list[n].charAt(i)  = target count++;
  34. for equals change the type of list1, list 2 to String, also chang ethe if statement in the second forloop to !list1[i].equals(list2[i])
Advertisement
Add Comment
Please, Sign In to add comment