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
JAVA CHALLENGE ZYBOOKs
exis [7]

Answer:

Replace  /* Your solution goes here */ with:

<em>System.out.println(randGen.nextInt(49) + 100);</em>

<em>System.out.println(randGen.nextInt(49) + 100);</em>

<em />

Explanation:

Required

Statements to print two random numbers between 100 and 149 (both inclusive)

First, the random numbers must be generated. From the template given, the random object, randGen, has been created.

The syntax to then follow to generate between the interval is:

<em>randGen.nextInt(high-low) + low;</em>

Where:

high = 149 and low = 100

So, the statement becomes:

<em>randGen.nextInt(149 - 100) + 100;</em>

<em>randGen.nextInt(49) + 100;</em>

<em />

Lastly, print the statements:

<em>System.out.println(randGen.nextInt(49) + 100);</em>

<em>System.out.println(randGen.nextInt(49) + 100);</em>

<em />

5 0
3 years ago
Several years ago, Jaime began to operate a small home business. He was very excited by the new features of Windows 95. These ne
Dmitriy789 [7]

1. A complete operating system rather than a graphical user interface running on top of MS-DOS.

After boot up, the system completely run without MS-DOS environment.

2. Improved windows control and appearance of windows

Windows 95 has a new system control that located on the upper left corner of each window as an icon. In the upper right of each window, it has a new designed system box. Usually, it displays "Minimize", "Maximize/Restore" and new added "Close" buttons.

3. New introduced Desktop

Not only to store minimized icons, Windows desktop in Windows 95 can store files, shortcuts and system icons such as "My Computer" and "Recycle Bin".

4. Right button menu

Right click an object in system usually can bring a pop-up menu with some items like "edit", "copy", "paste", "properties" and "help".

5. New help system

The help window can resize and jump to anywhere in the screen. It splits to two areas in which left side is the index or keyword window and the right side is the content window.

6. Task bar and start menu

Similar to the concept of reserved area in Windows 1.x, Windows 95 began to have a task bar to store the links that can active or inactive an running program and display some system information in the tray area. A start menu was include in the task bar can let user access the shortcuts to all programs in a tree structure menu system.

7. Build-in network support with dial-up for different protocols

The build-in dial-up with support of TCP/IP protocol made user easier to access Internet. In OSR2 version of Windows 95, Microsoft began to integrate Microsoft Internet Explorer in Windows 95.

8. Folder view of all kinds of files and resources

In Windows 95, files, drives, shortcuts and network resources can all be displayed in a folder view in the new Windows Explorer which replaced Program Manager in pervious version of Windows.

9. Support of 32 bit application, pre-emptive multitasking and thread

These functions made Windows 95 to have the ability to run more complex tasks and programs.

3 0
3 years ago
The software that controls the computer hardware and establishes standards for developing and executing applications best descri
victus00 [196]
An operating system such as windows or macos
4 0
4 years ago
How old is the oldest asian
fomenos

Answer:

100000000000000000000000000

7 0
4 years ago
Read 2 more answers
Create a table in your own database using the following statement.
neonofarm [45]

Answer:

Check the explanation

Explanation:

CREATE FUNCTION dbo.DateRange_sp4 ("at"StartDate DATE, "at"NumberofConsecutivedays INT) RETURNS "at"DateList TABLE ( DateID INT IDENTITY, DateValue DATE, Year SMALLINT, Quarter SMALLINT, Month SMALLINT, Week SMALLINT, DayOfWeek SMALLINT ) AS BEGIN DECLARE "at"Counter INT = 0; WHILE ("at"Counter < "at"NumberofConsecutivedays) BEGIN INSERT INTO "at"DateList VALUES ("at"Counter + 1, DATEADD(DAY, "at"Counter, "at"StartDate), DATEPART(YEAR, "at"StartDate), DATEPART(QUARTER, "at"StartDate), DATEPART(MONTH, "at"StartDate), DATEPART(WEEK, "at"StartDate), DatePart(WEEKDAY, "at"StartDate) ); SET "at"StartDate = DATEADD(day,"at"Counter + 1, "at"StartDate); SET "at"Counter += 1 END RETURN; END GO SELECT * FROM dbo.DateRange_sp4('2020-01-10', 20);

kindly check the screenshot below

7 0
3 years ago
Other questions:
  • What feature did we use to quickly apply the formatting shown in this image?
    9·1 answer
  • 5. Write a program to remove any duplicate letters from a word and display the new word maintaining the original order. For exam
    12·1 answer
  • instructor is describing a component that is always located on the CPU and accelerates the processing of instructions. Which com
    12·1 answer
  • What is the process called that occurs when you start up your computer? A Download B Restore C Boot D Copy
    12·2 answers
  • A(n) ____ is an entry in a cell that contains text such as "2016 Sales" or "Travel Expenses."
    10·1 answer
  • DRIVER ED
    13·2 answers
  • If you were investigating login issues on a Windows computer, which portion of the Event Viewer logs would be a good place to st
    7·1 answer
  • Output devices reproduce or display which of the following
    12·2 answers
  • describe at least five ways in which information technology can help studying subjects other than computing​
    6·1 answer
  • What does the "mesh" do in Augmented Reality?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!