/** * * Implement the method below that takes an array of int numbers as * input argument and returns Strin

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

/** * * Implement the method below that takes an array of int numbers as * input argument and returns Strin

Post by answerhappygod »

Implement The Method Below That Takes An Array Of Code Int Code Numbers As Input Argument And Returns Strin 1
Implement The Method Below That Takes An Array Of Code Int Code Numbers As Input Argument And Returns Strin 1 (372.66 KiB) Viewed 41 times
In Java,
Please do the implementation below the where that wrote "Yourimplementation" and write the same class as the pictures donot change anything thanks and there's information below classabout what you should write thanks and that's the Junit testproject all of the task should be pass thanks and please provideyour screen shot of your code that all of the task are passed withthe my junit test that i provided for you
/** * * Implement the method below that takes an array of <code>int</code> numbers as * input argument and returns String value indicate that all elements belonging to this input array * are in a sequence of increasing consecutive integers and returns * another String value if not consecutive * Consecutive integers are integers that come one after the other, * as in 5, 6, 7, 8, 9, etc. * <p> * <strong> You can assume that the input array is not empty and contains at * least 1 one element.</strong> * </p> * <p> * For example: * </p> * * <pre> * if inputarray. = {6, 7, 8, 9) then return "{6, 7, 8, 9} is consecutive" * if inputarray. = { 6, 7, 8, 9, 2, 9} then return "{ 6, 7, 8, 9, 2, 9} is NOT consecutive" * if inputarray. = { 1, 1, 1, 1} then return "{ 1, 1, 1, 1} is NOT consecutive" * if inputarray. = { 2, 3, 4, 5} then return "{ 2, 3, 4, 5) is consecutive" * </pre> * * * * @param inputarray input array of integer * @return String value see above * otherwise. */ public static String is Consecutive(int[] inputarray) { /* Your implementation of this method starts here. * Recall that : * 1. No System.out.println statements should appear here. Instead, you need to return the result. * * 2. No Scanner operations should appear here (e.g., input.nextInt()). Instead, refer to the input parameters of this method. *
@Test public void test_00_isConsecutive() { final int[] myList = { 3, 6 }; String n = ArrayUtility.isConsecutive (myList); assertEquals("{3, 6} is NOT consecutive",n); } @Test public void test_30_is Consecutive() { final int[] myList = {3}; String n = ArrayUtility.isConsecutive (myList); assertEquals("{3} is consecutive",n); } @Test public void test_01_isConsecutive() { final int[] myList = { 6, 7, 8, 9 }; String n = ArrayUtility.is Consecutive (myList); assertEquals("{6, 7, 8, 9} is consecutive",n); } @Test public void test_02_isConsecutive() { final int[] myList = { 6, 7, 8, 9,10 }; String n = ArrayUtility.isConsecutive (myList); assertEquals("{6, 7, 8, 9, 10} is consecutive",n); } @Test public void test_03_isConsecutive() { final int[] myList = { 69,10 }; String n = ArrayUtility.isConsecutive (myList); assertEquals("{69, 10} is NOT consecutive",n); }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply