One Direction * * Ask the user to enter integers. As long as the numbers are *
Question:
One Direction
*
* Ask the user to enter integers. As long as the numbers are
* all increasing (or equal) or decreasing (or equal), let them
* keep entering numbers. As soon as a number is entered that
* changes direction, however, stop and print the number
* of inputs, then "Wrong Direction".
*
* Example:
* Enter numbers with returns between
* 2
* 3
* 4
* 4
* 5
* 2
* 6 inputs
* Wrong direction
*/
public void oneDirection(){
// Leave these two lines
Scanner scan = new Scanner(System.in);
System.out.println("Enter numbers with returns between");
// Add the number to this line
System.out.println(" inputs");
// And leave this line.
System.out.println("Wrong direction");
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang