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
Mandarinka [93]
3 years ago
7

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

display all the integers, (2) display all the integers in reverse order, (3) display the sum of the integers, (4) display all values less than a limiting argument, and (5) display all values that are higher than the calculated average value. Save the file as ArrayMethodDemo.java.
Computers and Technology
1 answer:
Butoxors [25]3 years ago
3 0

Answer:

package b4;

public class ArrayMethodDemo {

public static void main(String[] args) {

 // Create an array to store 8 random integers.

 int[] integernumbers = { 3, 4, 6, 9, 5, 6, 7, 2 };

 // Call the display method to show the elements in the array.

 display(integernumbers);

 // Call the method to display the elements in reverse order.

 displayReverse(integernumbers);

 // Call the method to find the sum of the elements.

 sum(integernumbers);

 // Call the method to display all elements less than a limiting value, say 5.

 lessThan(integernumbers, 5);

 // Call the method to display all elements greater than the average of the array

 // elements.

 higherThan(integernumbers);

}

// Method to display the elements in the array.

// The method receives only a single argument which is the array.

// Loop through the array and at every cycle, print out each element

public static void display(int[] arr) {

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

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

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

 }

 System.out.println();

}

// Method to display the elements in the array in reverse order

// The method receives only a single parameter which is the array

// Loop through the array starting at the last index

// At every cycle, print out the elements in the array

public static void displayReverse(int[] arr) {

 System.out.print("All integers in the array in reverse : ");

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

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

 }

 System.out.println();

}

// Method to print out the sum of the elements in the array.

// The method receives only a single parameter which is the array.

// Declare a variable called sum to hold the sum of the elements

// Initialize sum to zero

// Loop through the array and cumulatively add each element to sum

// Print out the sum at the end of the loop

public static void sum(int[] arr) {

 int sum = 0;

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

  sum += arr[i];

 }

 System.out.println("The sum of the integers in the array is " + sum);

}

// Method to print all values in the array that are less than a limiting

// argument.

// The method has two parameters - the array and the limiting argument.

// Loop through the array and at every cycle,

// check if the current array element is less than the limiting argument.

// If it is, print it out. Else continue

public static void lessThan(int[] arr, int limitingargument) {

 System.out.print("All values less than the limiting argument (" + limitingargument + ") are: ");

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

  if (arr[i] < limitingargument) {

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

  }

 }

 System.out.println();

}

// Method to print all values in the array that are higher than the average of

// the array.

// The method has one parameter - the array.

// First, calculate the average of the array elements.

// Loop through the array and at every cycle,

// check if the current array element is greater than the average.

// If it is, print it out. Else continue

public static void higherThan(int[] arr) {

 int sum = 0;

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

  sum += arr[i];

 }

 double average = sum / arr.length;

 System.out.print("All values higher than the calculate average (" + average + ") is ");

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

  if (arr[i] > average) {

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

  }

 }

 System.out.println();

}

}

Explanation:

The program has been written in Java.

Please go through the comments in the code for explanation.

The source code has also been attached to this response.

Hope this helps!

Download java
You might be interested in
3. You are a network administrator responsible for all network platforms and services. The Teta Company currently has only one b
solniwko [45]

Answer:

1. Wired networks may give the appearance of a busy office full of the latest equipment, but in reality, wires can be an inefficient networking medium. They can limit signal strength as well as make it more difficult to expand and reorganize your network configuration.  Wireless networking is a viable and affordable alternative that offers the benefits of making your environment more flexible. A wireless infrastructure allows you to effortlessly reconfigure your office space as your company grows and changes, easily extend connectivity and also allows employees to be mobile more easily.

2. Review the advantages and consider the benefits to your organization:

Reduced cost of installation. It may be significantly less expensive to install wireless access points compared to wiring your office with Ethernet capabilities.

Flexibility. If you regularly expand or reorganize your office space, or need to accommodate a variety of network configurations, the rapid transition time from one configuration to another that wireless provides can help reduce your network downtime. In addition, you won't have to incur the costs associated with physically rewiring office space.

Convenient information access. With wireless, you'd have the ability to extend access to key information to anyone on your staff, from anywhere in the office, even when they aren't physically connected to your wired local area network (LAN) connection. Do members of your staff regularly work away from their desks or stations, but could benefit from anytime, anywhere access to important data? Could you improve productivity by increasing access to important company systems? Do you have business processes you could streamline by reducing the number of times employees have to go back to their wired connections?  Wireless LANs are the way to go, especially where there's no existing wired network. This is especially true in leased offices, where you can't go knocking holes in walls.

Your next step is to actually build a wireless LAN, which you'll do just like this:

Identify the equipment you want to buy, such as wireless notebooks, access points, wireless LAN adapters and wireless cards.

Determine the number of users who need to have access to the network. This will help you determine the number of access points you'll need.

Plan for the connection to your wired LAN, probably in a central location and in an open environment. Your goal is to maximize the access point's wireless range. The quoted range is a maximum of 300 feet, but that's very dependent on the existing environment--walls, water pipes, cables and so on all could decrease the range. The best thing to do is complete a site survey first; if that's not possible, assume a maximum range of 150 feet, as 300 could decrease throughput.

8 0
4 years ago
Read 2 more answers
After saving the changes she made, Sally notices that she used the word "home” too many times in her paragraph. She decides to m
Natasha_Volkova [10]

Answer:

c or a there both correct

Explanation:

8 0
4 years ago
Question 10 of 10
AnnyKZ [126]

Answer:

Explanation:B.

just took the test

3 0
3 years ago
Sigma Technology is a company based in Singapore, with branches in 24 countries. It needs multiple CAs in different locations to
seropon [69]

PKI trust model that should be used, is a distributed trust model.

  • A distributed trust is a trust model that gives power to different source while taking the power away from a single source and thereafter, shares that responsibility to the wide range of sources. It is important as it allows trust to flows through network, marketplaces and forums.

  • With the use of this distributed trust model, Sigma Technology can have multiple CAs in different locations to work on behalf of the company. And even if one is absence, other CAs can still issue certificate without any hindrances.

Conclusively, we can say that PKI trust model that should be used is a distributed trust model.

Learn more from:

brainly.com/question/14837773

8 0
3 years ago
Who designed the apple i computer in 1976?
guajiro [1.7K]

Steve jobs designed the first apple computer


6 0
3 years ago
Read 2 more answers
Other questions:
  • What event in the 1970s contributed to the current
    6·2 answers
  • What dod regulation governs the use of commercial wireless devices within the global information grid?
    13·1 answer
  • Use the image above to determine which toolbars will be displayed in the program you are using. SELECT ALL THAT APPLY
    11·2 answers
  • Which option allows you to customize the order of your data ?
    8·2 answers
  • Select the appropriate APA guidelines when typing a research paper.
    11·1 answer
  • Which of the following is a setting in both the Transparency panel and the Mirror panel?
    10·1 answer
  • Write a program that will sort an array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any ot
    10·1 answer
  • If a employee has a grade grater than or equal to 18, then he she will get 50% bonous on the basic pay. Otherwise, the employee
    5·1 answer
  • Pls help me Pls help me
    13·1 answer
  • Watch any film of the silent era. Choose a short film from any genre that is less than 30 minutes long. Write a review of your e
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!