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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started