Question: 1. Write the method makeNegativeArray(int [] nums). This method should create and return a new int [] of values that contain elements that are the

1. Write the method makeNegativeArray(int [] nums). This method should create and return a new int [] of values that contain elements that are the negatives of the elements in nums. You may assume that nums is not null (that it has at least one value in it).

Ex) int [] x = {2, 4, -3, 6, -4, -1, 0}

int [] y = makeNegativeArray(x);//y holds {-2, -4, 3, -6, 4, 1, 0}

// pre: nums is not null

// post: a new int [] containing negative version of elements in nums

public static int[] makeNegativeArray(int [] nums)

{

}

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!