1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kobusy [5.1K]
3 years ago
5

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
}
Computers and Technology
1 answer:
LuckyWell [14K]3 years ago
6 0

Methods are collections of named code blocks, that are executed when called or evoked.

<h3>The isSorted method</h3>

The isSorted method written in Java, where comments are used to explain each line is as follows

//This defines the isSorted method

   public static boolean isSorted(double[] myArr){

       //This iterates through the array

       for (int i = 0; i < myArr.length - 1; i++){

           //If the current element is greater than the next

           if (myArr[i] > myArr[i + 1]) {

               //This returns false

               return false;

           }

       }

       //This returns true, if the array is sorted

       return true;

   }

Read more about methods at:

brainly.com/question/19360941

You might be interested in
Jordan just wrote a secret message program in python that converts the number 7,095 to 1s and 0s. Which number system is Jordan
nevsk [136]

Answer:

Binary

Explanation:

Binary code is code that only entails 1s and 0s

7 0
3 years ago
Read 2 more answers
Which of the following code segments could be used to skip the first two characters of an input line (they may or may not be whi
marusya05 [52]

Answer:

Following are the code in the C++ Programming Language.

cin.get(dummy);

cin.get(dummy);

cin >> inputInt;

Explanation:

In the above code that is written in the C++ Programming Language, the first two code is written for the string character input from the user and it input or not input the whitespace characters and the last one is used for the input of the integer character from the user. The character variable they used that is 'dummy' and the integer variable they used is 'inputInt'.

7 0
3 years ago
âin order to aid a forensics investigation, a hardware or software ______________ can be utilized to capture keystrokes remotely
faltersainse [42]
(keystroke) logger. I'm hoping this is what you wanted.
5 0
4 years ago
Which of the following statements is true?
USPshnik [31]

Answer: (A) Computer science trends to deal with the data.

Explanation:

 The computer science basically tend to deal with the big data and data science as it is the emerging technologies with the upcoming years.

As, with the large amount of the data and high transmission rate we can easily developed new computing technologies with low budget.  

Data is basically defined as simple facts and figures and contain information that is very useful for developing the computing technology for study and processing the system.

Therefore, Option (A) is correct.

 

8 0
3 years ago
What are three ways science and technology are related and what are three ways they are different?
photoshop1234 [79]

Answer:

Science contributes to technology in at least six ways: (1) new knowledge which serves as a direct source of ideas for new technological possibilities; (2) source of tools and techniques for more efficient engineering design and a knowledge base for evaluation of feasibility of designs; (3) research instrumentation,

Explanation:

3 0
3 years ago
Other questions:
  • Which of the following careers is part of the Printing Technology pathway?
    10·1 answer
  • How do you give the brainliest answer to someone?
    8·2 answers
  • Individuals who require better speed and performance for graphics-intensive applications (e.g., video editing, gaming, etc.) pre
    8·1 answer
  • Carol typed a memo to distribute to everyone in her department. To create this memo, she used a _____. spreadsheet word processo
    8·2 answers
  • How does the actual amount left to spend differ from the budgeted amount for the remaining three months of the project?
    12·1 answer
  • Convert the following into binary system<br>and vice versa.<br>106​
    6·2 answers
  • Select the correct answer.
    9·1 answer
  • Write a recursive function is_pow2(n) that returns True if the positive integer n is an integer power of 2, and False otherwise.
    9·1 answer
  • It is recommended that systems administrators analyze logs in order to determine if they have been altered because monitoring ca
    14·1 answer
  • What does the x mean in .docx
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!