Question: USE JAVA In the box provided to answer this question, write the code for the method categorize, a method that returns a reference to an

USE JAVA

In the box provided to answer this question, write the code for the method categorize, a method that returns a reference to an array of int variables whose length is 3. The method receives a single argument numbers thats a reference to an array of int values. The method assigns values to the elements of the return result as per the following scheme: Element 0 holds the count of the number of elements in numbers that are non-positive, element 1 holds the count of positive odd-numbered elements in numbers, and element 2 holds the count of the positive even-numbered elements in numbers. Five sample runs with different array inputs are given on the Sheet for this Question. Note that showArray (again) simply displays the elements of the input array.

Sample arrays with sample Call

int[ ] numbers1 = {0, -1, 2, 2, 6};

result = categorize(numbers1);

showArray("Run 1 result:", result);

int[ ] numbers2 = {1, 5, 3, 7, 2, 1, 0, 8};

private static void showArray(String explanation, int[ ] array)

{

int len = array.length;

int indx;

System.out.println(explanation);

for (indx = 0; indx

System.out.printf("%d", array[indx]);

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!