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.

Answers

Answer 1

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:

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

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


Related Questions

Other Questions
what is 1/9+3/5= what is the fraction the diameter of a circle is 7 m. find its area and perimeter.Answer fast!!!!! I need a creative writing not more than 500 wordsIt can be a story , poem etcIt should have strong vocabulary What was the primary benefit of Robert Fultons Clermont steamboat invention?Group of answer choices. Travel time between New York City and Los Angeles was cut in half with the invention.Travel on canals became easier as canals were originally built to accommodate steamboatsSlaves could now be transported quicker and easier for auction in the South.Travel time decreased as the steamboat could now travel against the current. Your grandmother has given you a gift of $1500 for your birthday. You are thinking about your future andconsidering two different options on how to manage your money. Option A: You take all of your $1500 anddeposit it into a savings account that has a 5% interest rate per year. Option B: You spend $500 on a newApple Watch and deposit the remaining $1000 in a savings account that has a 5.5% interest rate per year..Which account would have the most in 10 years? 20 years? Mathematically, explain your reasoning.Which option would you choose and why?. Which expression is equivalent to 3(x - 2)+2x?-X3x5x - 25x -6 How many electrons does potassium have in its outside electron shell? Need Help Due TomorrowMUST SHOW WORK!dont bother answering if not going to show work factor: p26q(p26)2 Discuss how algae help support other life on earth? Which of the following expressions would give you the greatest quotient (answer to the division problem)? Explain when single-stranded or multistranded wire should be used. Help I need this answer before the day is over how does tannin leave the cell Briefly describe the factors and characteristics that influence conflict resolution. A substance that slows down the normal function of the centralnervous system is called a _____a. amphetamine.b. depressant.c. stimulant.d. hallucinogen. This is a political cartoon depicting a funeral for the Stamp Act. What happened that inspired this illustration? This system has ______ solutions By the 400 BCE only one, stable oligarchy remained in which city-state What is a shelperd?