Create an application containing an array that stores eight integers. The application should call five methods that in turn:
Display all the integers
Display all the integers in reverse order
Display the sum of the integers
Display all values less than a limiting argument
Display all values that are higher than the calculated average value.
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) {
// Write your code here
}
public static void displayReverse(int[] numbers) {
// Write your code here
}
public static void displaySum(int[] numbers) {
// Write your code here
}
public static void displayLessThan(int[] numbers, int limit) {
// Write your code here
}
public static void displayHigherThanAverage(int[] numbers) {
// Write your code here
}
}

Answers

Answer 1
Answer:

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();

   }

   

}

Sample Output:

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

Explanation:

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.


Related Questions

Page Setup options are important for printing a PowerPoint presentation a certain way. The button for the Page Setup dialog box is found in the
File tab.
Home tab.
Design tab.
Slide Show tab.

Answers

Answer: Design tab

Explanation:

The page setup simply refers to the parameters which are defined by a particular user which is vital in knowing how a printed page will appear. It allows user to customize the page layout. The parameters include size, page orientation, quality of print,margin etc.

It should be noted that page setup options are vital for printing a PowerPoint presentation in a certain way and the button for the Page Setup dialog box can be found in the design tab.

what is the best plugin for subscription sites?

Answers

Answer:

Explanation:

MemberPress. MemberPress is a popular & well-supported membership plugin. ...

Restrict Content Pro. ...

Paid Memberships Pro. ...

Paid Member Subscriptions. ...

MemberMouse. ...

iThemes Exchange Membership Add-on. ...

Magic Members. ...

s2Member.

Write a C program that right shifts an integer variable 4 bits. The program should print the integer in bits before and after the shift operation. Does your system place 0s or 1s in the vacated bits?

Answers

Solution :

#include<[tex]$\text{stdio.h}$[/tex]>

#include<conio.h>

void dec_bin(int number) {

[tex]$\text{int x, y}$[/tex];

x = y = 0;

for(y = 15; y >= 0; y--) {

x = number / (1 << y);

number = number - x * (1 << y);

printf("%d", x);

}

printf("\n");

}

int main()

{

int k;

printf("Enter No u wanted to right shift by 4 : ");

scanf("%d",&k);

dec_bin(k);

k = k>>4; // right shift here.

dec_bin(k);

getch();

return 0;

}

Which of the following is not the disadvantage of closed
network model?
Select one:
O Flexibility
O Public network connection
O Support
O External access​

Answers

Answer:

public network connection

Answer:

public network connection

is used for finding out about objects, properties and methods​

Answers

Answer:

science

Explanation:

Which of the following best explains how an analog audio signal is typically represented by a computer?
a. An analog audio signal is measured at regular intervals. Each measurement is stored as a sample, which is represented at the lowest level as a sequence of bits.
b. An analog audio signal is measured as a sequence of operations that describe how the sound can be reproduced. The operations are represented at the lowest level as programming instructions.
c. An analog audio signal is measured as input parameters to a program or procedure. The inputs are represented at the lowest level as a collection of variables.
d. An analog audio signal is measured as text that describes the attributes of the sound. The text is represented at the lowest level as a string.

Answers

Answer:

A. An analog audio signal is measured at regular intervals. Each measurement is stored as a sample, which is represented at the lowest level as a sequence of bits.

Explanation:

I took the test

a) Why is eavesdropping done in a network?
b) Solve the following using checksum and check the data at the
receiver:
01001101
00101000​

Answers

Answer:

An eavesdropping attack is the theft of information from a smartphone or other device while the user is sending or receiving data over a network.

Missing: checksum ‎01001101 ‎00101000

Which line of code will use the overloaded multiplication operation?

class num:
def __init__(self,a):
self.number = a

def __add__(self,b):
return self.number + 2 * b.number

def __mul__(self, b):
return self.number + b.number

def __pow__(self, b):
return self.number + b.number

# main program
numA = num(5)
numB = num(10)

Which line of code will use the overloaded multiplication operation?

class num:
def __init__(self,a):
self.number = a

def __add__(self,b):
return self.number + 2 * b.number

def __mul__(self, b):
return self.number + b.number

def __pow__(self, b):
return self.number + b.number

# main program
numA = num(5)
numB = num(10)

a) product = numA * numB
b) product = numA.multiply(numB)
c) product = numA.mul(numB

Answers

For multiplication one: product = numA * numB

For the addition: result = numA + numB

got 100 on this ez

(searched all over internet and no one had the answer lul hope this helps!)

Answer: First option: product = numA * numB

second option-numA + numB

Explanation:

What is the hamming distance between the following bits? Sent
bits: 101100111, Received bits: 100111001
Select one: 5. Or 3 or 6 or4​

Answers

I think

the hamming distance between the following bits its 5

Other Questions
Andy derives utility from two goods, potato chips (Qp) and Cola (Qc). Andy receives zero utility unless he consumes some of at least one good. The marginal utility that he receives from the two goods is given as follows: Qp MUp Qc MUc 1 12 1 24 2 10 2 22 3 8 3 20 4 6 4 18 5 4 5 16 6 2 6 14 7 -2 7 12 8 4 8 10 Refer to Scenario, what is the total utility that Andy will receive if he consumes 5 units of potato chips (Qp) and no Cola drink (Qc)? The shapes of the horizontal cross-sections of the cylinder below are not allcongruent.A. TrueB. FalseSUBMET yvonne is 3 years younger than her sister.the sum of thier ages is 25 years. HELP IS STUDY ISLAND I NEED THIS NOW Match the following quote from the Declaration of Independence to the Enlightenment Thinker who inspired it, We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the pursuit of Happiness.A. Voltaire C. Thomas Hobbs B .Baron De Montesquieu D. John Locke Easy points: Is this a good paragraph for my biology class??The question was why is it important for soil to contain nitrogen, phosphorus, magnesium, and potassium.Soil is one of the main sources of nutrients needed by plants in order to grow. Nitrogen is used by plants for leaf growth and green color. Without nitrogen in the soil, the plant wouldnt grow tall and produce enough food.Phosphorus is used by plants to help form new roots, make seeds, fruit and flowers.This is crucial because crops take up phosphorus only from the soil solution.Potassium helps plants form strong stems and fast growth. It also increases disease resistance.It triggers activation of enzymes and is essential for production of ATP. Magnesium is the central core of the chlorophyll molecule in the plants tissue. If Mg is deficient, the shortage of chlorophyll results in poor and stunted growth. Approximate, in square meters, the area of a circle with radius = 58.2 m. (Round your answer to three decimal places.) The decision guaranteeing the rights of Mexican Americans to serve on juries most directly resulted from which of the following historical processes during this period? The height of a cone is two times its base diameter. What is the volume of the cone in terms of its base radius ? A broker charges 70 per square foot to install windows how much does it cost to install the windows shown How did the Enlightenment shape the intellectual and ideological thinking that affected reform and ideological thinking that affected reform and revolution after 1750? (Need a legit answer, please. Thesis statement) Which of the following is the best representation of the limiting factors affecting the elk population in this ecosystem?O Number of scavengers, number of wolves, number of scientists studying Yellowstone.Number of scavengers, and harshness of winterNumber of wolves, and harshness of winter.The elk have no limiting factors Please help me anyone ASAP?!!! A sound wave travels with a velocity of 1.5 m/s and has a frequency of 500 Hz. What is its wavelength? Lena bought new inline skates for $44.99. The sales tax was $4.13. How much did Lena spend in all for her new inline skates? A large school district claims that 80% of the children are from low-income families. 150 children from the district are chosen to participate in a community project. Of the 150 only 70% are from low-income families. The children were supposed to be randomly selected. Do you think they really were In a word-processing program, what are the easily accessible icons that allow you to print, save and change fonts with a click of a button?A- tool bar B- keyboard shortcuts C- preferencesD- printing options Select all the expressions that are equivalent to 20% of 150. Anyone else keep seeing this person giving links? If u do, report them because they are scamming I need help please!!