Question: Take in any integer array perform several operations on that array. Determine if the values in array are all going up, if the values in

Take in any integer array perform several operations on that array. Determine if the values in array are all going up, if the values in the array are all going down, and return an array that contains a set number of values greater than a particular value.

* An array that is going up will contain values that increase. [1,2,3,4,5] is going up. [1,2,3,0,8] is not going up.

* An array that is going down will contain values that decrease. [5,4,3,2,1] is going down. [5,4,9,1,0] is not going down.

Starter code

public class ArrayFunHouseTwo {

/** * Return true if all numbers in numArray are in increasing order. *

[1,2,6,9,23] returns true.

*

[1,2,2,9] returns false.

*

[9, 11, 13, 8] returns false.

* * @param numArray The input array. * @return True if the elements of numArray are increasing. */ public static boolean goingUp(int[] numArray) { return true; }

/** * Return true if all numbers in numArray are in decreasing order. *

[31,12,6,2,1] returns true.

*

[9,2,2,1] returns false.

*

[31, 20, 10, 15, 9] returns false.

* * @param numArray The input array. * @return True if the elements of numArray are decreasing. */ public static boolean goingDown(int[] numArray) { return true; }

/** * Return an array that contains the first count values that are larger than * x. If there are not enough values to fill the returned array, then * the array is zero filled. *

[1,2,3,4,5,6,7,8,9,10,11,6],3,5 would return [6,7,8].

*

[1,2,3,4,5,6,7,8,9,10,11,6],3,10 would return [11,0,0].

* * @param numArray The input array. * @param count The size of the returned array. * @param x The returned values are larger than x. * @return An array of size count with the first elements of numArray greater than x. */ public static int[] getCountValuesBiggerThanX(int[] numArray, int count, int x) { return null; } }

Sample Data :

[1,2,3,4,5,6,7,8,9,10]

[1,2,2,4]

[1,2,3,9,11,20,30]

[9,8,7,6,5,4,3,2,0,-2]

[3,6,9,12,15,18,21,23,19,17,15,13,11,10,9,6,3,2,1,0]

Sample Output :

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

is going Up? true

[1, 2, 2, 4 ]

is going Up? false

[1, 2, 3, 9, 11, 20, 30]

is going Up? true

[9, 8, 7, 6, 5, 4, 3, 2, 0, -2]

is going Up? false

[3, 6, 9, 12, 15, 18, 21, 23, 19, 17, 15, 13, 11, 10, 9, 6, 3, 2, 1, 0]

is going Up? false

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

is going Down? false

[1, 2, 3, 9, 11, 20, 30]

is going Down? false

[9, 8, 7, 6, 5, 4, 3, 2, 0, -2]

is going Down? true

[3, 6, 9, 12, 15, 18, 21, 23, 19, 17, 15, 13, 11, 10, 9, 6, 3, 2, 1, 0]

is going Down? false

[3, 6, 9, 12, 15, 18, 21, 23, 19, 17, 15, 13, 11, 10, 9, 6, 3, 2, 1, 0]

first 7 values greater than 9 [12, 15, 18, 21, 23, 19, 17]

first 5 values greater than 15 [18, 21, 23, 19, 17]

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!