Question: Write the method public static int goingWhichWay(int [] myArray) that takes an integer array myArray. Do not change myArray. If myArray is already sorted in
Write the method public static int goingWhichWay(int [] myArray) that takes an integer array myArray. Do not change myArray. If myArray is already sorted in strictly increasing order, output "UP" to the console window, and return the value 111. If myArray is already sorted in strictly decreasing order, output "DOWN" to the console window and return the value 222. If neither of these is true for myArray, output "NEITHER" to the console window, and return the value 333. Examples:
myArray 3 8 17 25 89 94 should print "INCREASING" and return 111. myArray 77 66 55 33 22 11 should print "DECREASING" and return 222. myArray 20 30 50 40 10 5 should print "NEITHER" and return 333. myArray 20 30 50 50 70 90 should print "NEITHER" and return 333 (it is not strictly increasing).
------------------------------------------------------------------------------------------------------------------------
public static int goingWhichWay(int [] myArray) {...}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
