Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Help me with this ASAP public static int[] task3(int[] seq, int[] indices) { int[] result = null; /* Your task is to implement this

Please Help me with this ASAP

public static int[] task3(int[] seq, int[] indices) { 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.

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

the below junit test should pass

/* * Tests related to Task 3 */ @Test public void test_task3_01() { int[] seq = {3, 7, 4, 5}; int[] indices = {2, 1, 3}; int[] result = Utilities.task3(seq, indices); int[] expected = {4, 7, 5}; /* elements at indices 2, 1, 3 of `seq` */ assertArrayEquals(expected, result); } @Test public void test_task3_02() { int[] seq = {3, 7, 4, 5}; int[] indices = {2, -1, 0, 1, -2, 5, 3, 1, 0, 4}; /* invalid indices: -1, -2, 5, 4 */ int[] result = Utilities.task3(seq, indices); int[] expected = {4, 3, 7, 5, 7, 3}; assertArrayEquals(expected, result); } @Test public void test_task3_03() { int[] seq = {}; int[] indices = {2, -1, 0, 1, -2, 5, 3, 1, 0, 4}; int[] result = Utilities.task3(seq, indices); int[] expected = {}; assertArrayEquals(expected, result); } @Test public void test_task3_04() { int[] seq = {3, 7, 4, 5}; int[] indices = {-1, -2, 5, 4}; /* invalid indices: -1, -2, 5, 4 */ int[] result = Utilities.task3(seq, indices); int[] expected = {}; assertArrayEquals(expected, result); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

Define marketing concepts.

Answered: 1 week ago

Question

1 what does yellow colour on the map represent?

Answered: 1 week ago