Question: Please use Java Problem 4. Sorted or not (SortOrNot.java) Descriptions: Write a Java class named SortOrNot that will check whether a given array is already
Problem 4. Sorted or not (SortOrNot.java) Descriptions: Write a Java class named SortOrNot that will check whether a given array is already sorted in non-descending order or not. This class will include the following methods: 5) isSorted(): this method has one parameter which is an integer array. It will return true if the given array is sorted in non-descending order, or return false if the array is not sorted non-descendingly. 6) display(): this method has one parameter which is an integer array. It will display each element in the array. 7) main() method: Generate an integer array of length 5, and ask the user the enter the value of each of the five elements. Call the issorted method by passing the array numbers, and display the message on whether it is sorted or not. Outputs: $java SortedorNot The array is: 20 0 -5 2 8 The array is not sorted non-descendingly. $java SortedorNot The array is: 5 4 3 2 1 The array is not sorted non-descendingly. $java SortedorNot 11111 The array is sorted non-descendingly
Step by Step Solution
There are 3 Steps involved in it
To solve this problem we need to create a Java class named SortOrNot with the specified methods Lets ... View full answer
Get step-by-step solutions from verified subject matter experts
