Question: Please ASAP public static int[] task3(int[] seq) { int[] result = null; /* Your task is to implement this method, * so that running TestUtilities.java

Please ASAP

public static int[] task3(int[] seq) { int[] result = null; /* Your task is to implement this method, * so that running TestUtilities.java will pass all JUnit tests. * * Recall from Week 1's tutorial videos: * 1. No System.out.println statements should appear here. * Instead, an explicit, final `return` statement is placed for you. * 2. No Scanner operations should appear here (e.g., input.nextInt()). * Instead, refer to the input parameters of this method. * 3. Do not re-assign any of the parameter/input variables. */ // Your implementation of this method starts here. int sizeOfArray = seq.length; int myCounter = 1; if (sizeOfArray == 0) { result = new int[0]; }else{ for (int i = 1; i

result = new int[myCounter]; int myCounter2 = seq[0]; int arrayCounter = 1; int myCounter3 = 0; for (int i = 1; i

// Do not modify this return statement. return result; }

can u modify this to pass

@Test public void test_task3_1() { int[] seq = {3, 1, 1, 3, 2, 4}; int[] expected = {3, 1, 1, 1, 2, 2, 2, 2}; assertArrayEquals(expected, Utilities.task3(seq)); }

@Test public void test_task3_2() { int[] seq = {3, 0, 1, 3, 2, 4}; int[] expected = {1, 1, 1, 2, 2, 2, 2}; assertArrayEquals(expected, Utilities.task3(seq)); } @Test public void test_task3_3() { int[] seq = {3, 0, 1, 0, 2, 0}; int[] expected = {}; assertArrayEquals(expected, Utilities.task3(seq)); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!