Skip to content
Advertisement

Ordered or unordered Sequence problem in java

I am facing problem in solving the question below:- (can someone please help????)

Write a program that reads a sequence of integer numbers and outputs true if the sequence is ordered (in ascending or descending order), otherwise, false. Keep in mind, if a number has the same value as the following number, it does not break the order. The sequence ends with 0. Do not consider this number as a part of the sequence. The sequence always has at least one number (excluding 0).

code which I wrote(For this code I am getting runtime error)…..

JavaScript

Advertisement

Answer

Your code was a little bit messy, I will post a cleaned up version and explain the single steps.

JavaScript

}

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement