CAN SOMEONE LOOK TO SEE WHERE I DID WRONG. i have 3/5 rightnow(Adapted from UW CSE 142 Summer 2018 Practice Midterm) Write a static method named isConsecutive that accepts an array of ints as a parameter and returns true if the array of integers consists entirely of an increasing sequence of consecutive integers and returns false otherwise Consecutive integers are inters that come one after the other, as in 5, 6, 7, 8, 9, etc. For example, if a variable called arr stores the following values: [16, 17, 18, 19] a call on isConsecutive (arr) should return true. If instead are stored the following sequence of values: [16, 17, 18, 19, 20, 19] a call on isConsecutive (arr) should return false An array of fewer than two elements is considered to be consecutive, and you may assume that the given array is not null. public static boolean isConsecutive (int[] arr) { if (arr. length >= 3) { int middle arr.length/2; return are[middle-1]+1 == arr(middle] && arr[middle] +1 == arr(middleti] } else { return false; isConsecutive([16, 17, 18, 19]) OK isConsecutive([16,17,18,19,20,19]) returned true expected false isConsecutive([5]) returned false expected true isConsecutive([-1,0,1]) OK isConsecutive([16,18,17,19]) OK 3 / 5 OK You must get all 5 examples correct to earn credit! Show transcribed image text (Adapted from UW CSE 142 Summer 2018 Practice Midterm) Write a static method named isConsecutive that accepts an array of ints as a parameter and returns true if the array of integers consists entirely of an increasing sequence of consecutive integers and returns false otherwise Consecutive integers are inters that come one after the other, as in 5, 6, 7, 8, 9, etc. For example, if a variable called arr stores the following values: [16, 17, 18, 19] a call on isConsecutive (arr) should return true. If instead are stored the following sequence of values: [16, 17, 18, 19, 20, 19] a call on isConsecutive (arr) should return false An array of fewer than two elements is considered to be consecutive, and you may assume that the given array is not null. public static boolean isConsecutive (int[] arr) { if (arr. length >= 3) { int middle arr.length/2; return are[middle-1]+1 == arr(middle] && arr[middle] +1 == arr(middleti] } else { return false; isConsecutive([16, 17, 18, 19]) OK isConsecutive([16,17,18,19,20,19]) returned true expected false isConsecutive([5]) returned false expected true isConsecutive([-1,0,1]) OK isConsecutive([16,18,17,19]) OK 3 / 5 OK You must get all 5 examples correct to earn credit!
Expert Answer
Answer to CAN SOMEONE LOOK TO SEE WHERE I DID WRONG. i have 3/5 right now…