subject

Write a static method named isSorted that takes an array of real numbers as a parameter and that returns true if the list is in sorted (nondecreasing) order and false otherwise. For example, if variables named list1 and list2 refer to arrays containing {16.1, 12.3, 22.2, 14.4} and {1.5, 4.3, 7.0, 19.5, 25.1, 46.2} respectively, the calls of isSorted(list1) and isSorted(list2) should return false and true respectively. Assume the array has at least one element. A one-element array is considered to be sorted. Test your code with the following class:
public class TestIsSorted {
public static void main(String[] args) {
double[] a1 = {16.1, 25.3, 12.2, 44.4};
double[] a2 = {1.5, 4.3, 7.0, 19.5, 25.1, 46.2};
double[] a3 = {42.0};
System. out. println(isSorted(a1)); // false
System. out. println(isSorted(a2)); // true
System. out. println(isSorted(a3)); // true
}
// your code goes here
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 06:30
When early motion pictures played in movie theaters, they were often accompanied by live organ or piano music. which of the following are the most likely reasons that this happened? (select all that apply). the music was provided to distract audience members from the loud sounds made when filmstrips were changed. the music accompanied the movies because the movies were silent and audiences were used to hearing music during plays in theaters. the music usually was played before, and sometimes after the movie, as an alternative form of entertainment. the music viewers to interpret the dramatic action in the films.
Answers: 2
question
Computers and Technology, 23.06.2019 18:30
Write a program that prints the day number of the year, given the date in the form month-day-year. for example, if the input is 1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. the program should check for a leap year. a year is a leap year if it is divisible by 4, but not divisible by 100. for example, 1992 and 2008 are divisible by 4, but not by 100. a year that is divisible by 100 is a leap year if it is also divisible by 400. for example, 1600 and 2000 are divisible by 400. however, 1800 is not a leap year because 1800 is not divisible by 400.
Answers: 3
question
Computers and Technology, 23.06.2019 22:30
Lakendra finished working on her monthly report. in looking it over, she saw that it had large blocks of white space. what steps could lakendra take to reduce the amount of white space?
Answers: 3
question
Computers and Technology, 24.06.2019 08:30
Aconsumer would pay an extra they used the rent to own program to buy the computer, rather than using cash. for all of the items, is the cheapest option over the life of the contract. the most expensive overall option is to use purchase the item.
Answers: 2
You know the right answer?
Write a static method named isSorted that takes an array of real numbers as a parameter and that ret...
Questions
question
Mathematics, 25.03.2020 21:28
question
Mathematics, 25.03.2020 21:29
question
Mathematics, 25.03.2020 21:29