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
Maslowich
3 years ago
12

Implement the ArrayMethod application containing an array that stores eight integers. The application should call the following

five methods: 1. display - should display all the integers 2. displayReverse - should display all the integers in reverse order 3. displaySum - should display the sum of the integers 4. displayLessThan - should display all values less than a limiting argument 5. displayHigherThanAverage - should display all values that are higher than the calculated average value.
Computers and Technology
1 answer:
AveGali [126]3 years ago
8 0

Answer:

public static void display(int [] arr){

   System.out.print("Arrays: ");

       for(int i =0;i<arr.length;i++){

           System.out.print(arr[i]+" ");

       }

       System.out.println();

   }

   

public static void displayReverse (int [] arr){

   System.out.print("Arrays in reverse order: ");

       for(int i=arr.length-1;i>=0;i--){

           System.out.print(arr[i]+" ");

       }

       System.out.println();

   }

   

public static int displaySum (int [] arr){

   System.out.print("Sum: ");

   int sum = 0;

       for(int i =0;i<arr.length;i++){

           sum+=arr[i];

       }

       return sum;

   }

   

public static void displayLessThan (int [] arr, int num){

       System.out.print("Less than "+num+": ");

       for(int i =0;i<arr.length;i++){

           if(arr[i]<num){

               System.out.print(arr[i]+" ");

           }

       }

       System.out.println();

   }

public static void displayHigherThanAverage  (int [] arr){

       System.out.print("Higher than average: ");

       int sum = 0;

       for(int i =0;i<arr.length;i++){

           sum+=arr[i];

       }

       float average = sum/arr.length;

       for(int i =0;i<arr.length;i++){

           if(arr[i]>average){

               System.out.print(arr[i]+" ");

           }

       }

       System.out.println();

   }

Explanation:

<em>The methods were written in Java. See attachment for explanation where I used comments to explain each lines.</em>

<em>Note that lines that begin with double slash (//) are comments</em>

Download txt
You might be interested in
After class a student asked why you would ever use a heap instead of a binary search tree. Provide a good explanation for why an
sertanlavr [38]

Answer:

Heap is useful when you want to find max/min element in the given list

BinarySearchTree is used if you need sorted elements of the list

Explanation:

Heap is Good at finding Min/Max and it's time complexity is  (O(1)), while BST is good at all finds (O(logN)). Insert is O(logN) for Heap and BSTstructures..

Max Heap ensures that elements on higher levels are greater than elements at lower level

MinHeap ensures that elements on higher levels are lesser than elements at lower level

BST gives sorted elements by following order (left,root,right).If we want sorted elements we can go with BST

5 0
3 years ago
What happens in the development phase of the software development life cycle?
Olin [163]

Answer: Planning the solution, look and feel of the software interface

5 0
2 years ago
To add artwork to a slide, the slide must contain a placeholder. <br> a. True <br> b. False
valina [46]
The answer is True.  To add artwork to a slide, the slide must contain a placeholder. <span>Once </span>artwork<span> is inserted into a </span>placeholder<span>, it can be moved around the </span>slide<span>.</span>
5 0
4 years ago
The ____ operator executes one of two expressions based on the results of a conditional expression. Group of answer choices
Mars2501 [29]

Corrected or Complet Question

The ____ operator executes one of two expressions based on the results of a conditional expression.

a. .

b. ( )

c. ,

d. ?:

Answer:

(d) ? :

Explanation:

The ternary operator (? :) is an operator that executes one out of two expressions based on the results of a conditional expression. It is a faster or shorthand way of writing an if ... else statement. The operator checks the conditional expression and depending on whether it is true or false, one of its two statements will be executed. For example:

 String correct = (4 < 5) ? "yes" : "no" ;

In the code above,

i. the conditional statement is (4 < 5) and this will be tested for to return true or false.

ii. the first expression (the one after the ?) is "yes" which will be executed if the conditional statement returns true.

iii. and the second expression (the one after the : ) is "no" which will be executed if the conditional statement returns false.

Therefore, since the conditional expression returns true for 4 < 5, the first expression will be executed. i.e "yes". This means that the String variable <em>correct </em> will have a value of "yes".

8 0
3 years ago
Read 2 more answers
The spoken version of your company's purpose is called
beks73 [17]

Answer:

The answer to this question is given below in the explanation section. The correct answer is A

Explanation:

The spoken version of the company's purpose is also called an elevator pitch. because it has to be short enough to fit into a conversation that takes place on an elevator.

however the other options are not correct that tells the purpose of a company, because the vision statement shows what you will be at what stage in next coming year (in terms of growth, product /services etc). Your values are about what uniqueness you have in your product/service etc that you are providing to your customers/clients. While differentiation is not a spoken version of your company.

7 0
4 years ago
Other questions:
  • Write a Python program that gets a number using keyboard input. (Remember to use input for Python 3 but raw_input for Python 2.)
    8·1 answer
  • As referenced in this Canvas guide (Links to an external site.), Canvas is best viewed at a minimum of 800x600 pixels, which is
    5·1 answer
  • Energy is defined as stored energy
    13·2 answers
  • Gathering information with your eyes is called
    13·2 answers
  • How do solar system and galaxies differ?
    9·1 answer
  • When adapting graphs for slides,
    6·1 answer
  • A contact list is a place where you can store a specific contact with other associated information such as a phone number, email
    8·1 answer
  • HELP!! TIMED TEST!! Match the item to its description. 1. icons place where frequently used programs can be opened 2. Quick Laun
    13·1 answer
  • Clocks (also called timers) are essential to the operation of any multiprogrammed system. They maintain the time of day, and pre
    9·1 answer
  • Can i get any information on this website i'd like to know what its for ?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!