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
Simora [160]
3 years ago
12

Create an application containing an array that stores eight integers. The application should call five methods that in turn:

Computers and Technology
1 answer:
Rus_ich [418]3 years ago
6 0
<h2><u>Answer</u>:</h2>

public class ArrayMethodDemo {

   public static void main (String args[]) {

       int[] numbers = {12, 15, 34, 67, 4, 9, 10, 7};

       int limit = 12;

       display(numbers);

       displayReverse(numbers);

       displaySum(numbers);

       displayLessThan(numbers, limit);

       displayHigherThanAverage(numbers);

   }

   

   public static void display(int[] numbers) {

       

       //Message to be displayed before printing out the numbers

      System.out.print("Numbers in the array: ");

       

       //loop through the numbers in the array and print each number

       for(int x: numbers){

           System.out.print(x + " ");

       }

       

       //print a new line

       System.out.println();

   }

   

   public static void displayReverse(int[] numbers) {

       

       //Message to be displayed before printing out the reverse of the array

       System.out.print("Reverse of the array numbers: ");

       

       

       //loop through the array starting from the last index

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

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

       }

       

       //print a new line

       System.out.println();

   }

   

   public static void displaySum(int[] numbers) {

       

       //initialize the sum variable

       int sum = 0;

       

       //loop through the array and add each element to sum

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

           sum += numbers[i];

       }

       

       //print out the sum

      System.out.println("Sum: "  + sum);

       

   }

   

   public static void displayLessThan(int[] numbers, int limit) {

       

       //Text to be displayed before printing values less than the limit

       System.out.print("Values less than limit (" + limit + "): ");  

       //loop through the array and print numbers lower than the specified limit

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

           if(numbers[i] < limit){

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

           }

       }

       

       //print a new line

       System.out.println();

   }

   

   public static void displayHigherThanAverage(int[] numbers) {

       //initialize the average variable

       double average = 0.0;

       

       //initialize the sum variable

       int sum = 0;

       

       

       //loop through the array and add each element to sum

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

           sum += numbers[i];

       }

       

       //calculate the average

      average = sum / numbers.length;

       

       //Message to be displayed before printing the values higher than the average

       System.out.print("Values higher than average (" + average + "): ");

       

       

       //loop through the array and print numbers higher than the calculated average

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

           if(numbers[i] > average){

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

           }

       }

       

       //print a new line

       System.out.println();

   }

   

}

<h2><u>Sample Output:</u></h2>

Numbers in the array: 12 15 34 67 4 9 10 7  

Reverse of the array numbers: 7 10 9 4 67 34 15  

Sum: 158

Values less than limit (12): 4 9 10 7  

Values higher than average(19.0):34 67

<h2>Explanation:</h2>

The code above contains comments explaining important parts of the code. Kindly go through the comments. A sample output, arising from running the application, has also been added to ace understandability.

You might be interested in
what is musical technology specifically, the origins of its genesis &amp; its importance to the baroque era
ki77a [65]

Answer:

There were three important features to Baroque music: a focus on upper and lower tones; a focus on layered melodies; an increase in orchestra size. Johann Sebastian Bach was better known in his day as an organist. George Frideric Handel wrote Messiah as a counterargument against the Catholic Church

3 0
3 years ago
How does the browser display the same webpage whether you enter the URL or the IP address in the address bar? What system transl
ASHA 777 [7]
Your browser references a DNS server that translates a word or phrase of a url into an IP and then tells your browser what the IP address is so the browser can navigate to it. My google is not working atm sorry but you can google "what does DNS stand forin networking" and get an answer.
8 0
4 years ago
Who are the key players in the internet
Anna007 [38]
Gamers my dude, dank memes are also the internet's finest minds
4 0
3 years ago
Which two related organizations are responsible for managing the top-level domain name space and the root domain name system (dn
juin [17]

I guess the correct answers are,

IANA (Internet Assigned Numbers Authority)

ICANN (Internet Corporation for Assigned Names and Numbers)

Thе Intеrnеt Assignеd Numbеrs Authοrity (IANA) is a functiοn οf, a nοnprοfit privatе Amеrican cοrpοratiοn that οvеrsееs glοbal IP addrеss allοcatiοn, autοnοmοus systеm numbеr allοcatiοn, rοοt zοnе managеmеnt in thе Dοmain Namе Systеm (DNS), mеdia typеs, and οthеr Intеrnеt Prοtοcοl-rеlatеd symbοls and Intеrnеt numbеrs.

Thе Intеrnеt Cοrpοratiοn fοr Assignеd Namеs and Numbеrs (ICANN /ˈaɪkæn/ ЕYЕ-kan) is a nοnprοfit οrganizatiοn rеspοnsiblе fοr cοοrdinating thе maintеnancе and prοcеdurеs οf sеvеral databasеs rеlatеd tο thе namеspacеs and numеrical spacеs οf thеIntеrnеt, еnsuring thе nеtwοrk's stablе and sеcurе οpеratiοn.

6 0
3 years ago
If a packet is highlighted by black, what does it mean for the packet?
KATRIN_1 [288]

Answer:

If a packet is highlighted by black what does it mean for the packet It shows that there is a bad Spanning. Hope this helps! Pls give me BRAINLIEST!!!! =)

8 0
4 years ago
Other questions:
  • "what is the #1 resource used when researching a product online?"
    5·1 answer
  • Debuted by the Lumiere Brothers, a hand cranked device that showed moving pictures to an audience​
    7·1 answer
  • 16235 to the nearest ten thousand
    13·2 answers
  • This short cut key combination deletes a line in most text documents.
    8·1 answer
  • What does the binary odometer show about representing large numbers?
    8·1 answer
  • Python exercise grade 10
    7·1 answer
  • How do you move a slide to another location in you your<br> presentation?
    7·1 answer
  • When you hear the word “stress” what does it mean to you? How does stress affect you and what do you do to cope with stress
    9·1 answer
  • What happens when there is a data fail?
    6·2 answers
  • Rafter type and Truss type?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!