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
Write a program that prints the following text: In C, lowercase letters are significant. main() is where program execution begin
hodyreva [135]

Answer:

Program:

#include <stdio.h> // header file

int main() // main function

{

   printf("In C, lowercase letters are significant. main() is where program execution begins. Opening and closing braces enclose program statements in a routine. All program statements must be terminated by a semicolon."); // print statement which print the text which is said by the question to print.

return 0; // return statement

}

Output:

  • The above code print the text which is defined by the question to print

Explanation:

  • The above code is in the c programming language.
  • The first line of the code is a header file which is used to specify the meaning of the symbols used in programs.
  • The second line of the code is the main function, from which the execution will starts.
  • The third line of the code is the print statement which prints the above text.
  • The fourth line of the code is a returned statement that returned 0 from where the function is called.
7 0
3 years ago
Explain how computer system is different from computer in 150 words
Zina [86]

Answer:

To be distinguished from the physical or hardware components of a computer, programs are collectively referred to as software. A computer system, therefore, is a computer combined with peripheral equipment and software so that it can perform desired functions.

A computer is a device that does certain things (mostly very basic data manipulation and mathematical functions), just as a building is a device that does certain things (such as housing offices or apartments). What makes a computer special is that it does these things very very quickly. A computer system is a mechanism that incorporates multiple computers along with other things like data storage devices, networks, and data paths (ways to move data around among storage devices and computers), as well as software (rules for how to do things), procedures and processes and protocols and on and on. A computer system performs a rather complex function, just as a city is a system that involves multiple buildings along with roads, sewage treatment plants, water and electrical systems and many other things that enable it to perform a function considerably more complex than the function performed by a building.

A major advance in the field of computing was the advent of networking. Before that, computers had to be near each other in order to communicate with each other and computer systems typically existed in a relatively small physical location where all the computers were in the same place. If you see a movie released in the period from roughly 1950 to 1980, you will note that computers and computer systems were typically depicted as gigantic things located in a large room. With networking, a computer system might have computers in one place, remote access devices in another place, and other computers in other places. Thus a building might have computers and terminals and printers and what have you all over it, all capable of communicating with each other. The internet, which enables world wide networks, has made it possible to have computer systems that consist of thousands of computers (or more), located all over the globe.

a computer is like an engine whereas a computer system is like a vehicle (a car or truck or boat) that contains one or more engines and does something more complex than what the engine does. But the engine is the essential component that enables the vehicle to do what it does. a computer exists in a single place and does a primitive set of functions. A computer system combines a computer with many other things to perform a complex set of functions. It can also exist in a single place, but it may exist in many places at the same time.

Explanation:

Pleeeeeeeeeeeeeeeeeeez mark me as brainliest i did this so hardly so plez i beg u and cry to mark me as brainliest and give a vote of full and give a thanks

7 0
3 years ago
How do I connect my CSS file and HTML page together? it's just not wanting to work for me. 
kiruha [24]
In the <head> part of your HTML, you reference the CSS like this:

<link<span> rel="stylesheet" type="text/css" href="thecss.css"</span><span>>
</span>
If it is still not working, there could be many kinds of mistakes. Take it one step at a time and start simple, or share your HTML and CSS so we can have a look.
4 0
3 years ago
Write a Dice Game program that generates two random dice values between 1 and 6 for you, and 2 for the computer. You get to roll
charle [14.2K]

Answer:

#include <iostream>

#include <time.h>

#include <string>

using namespace std;

int main(){

srand(time(NULL));

cout<<"Throw dice"<<endl;

int b =0;

int a=0;

a=rand()%6;

b=rand()%6;

for (int i =0;i<1;i++)

{cout<<"dice one: "<<a<<endl;}

for (int i =0;i<1;i++)

{cout<<"dice two: "<<b<<endl;}

if(a>b)

{cout<<"first dice won"<<endl;}

if(b>a)

{cout<<"second dice won"<<endl;}

else{cout<<"they are same"<<endl;

return main();

}

return 0;

}

Explanation:

/*maybe it help you it is almost done*/

6 0
2 years ago
when an overridden method is called from within a subclass, it will always refer to the version of that method defined by the (a
bija089 [108]

Option b is correct. When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the subclass.

Subclasses are classes that can be created by adding new functionality to a parent class, such as new object variables or new methods. In terms of automata theory, a subclass expands the state transition table with new rows and states. However, by overriding (changing) existing functionality, the majority of OO programming languages also enable us to derive subclasses from parent classes. When implementing a class, all that is required to be specified is the new or updated functionality thanks to inheritance mechanisms between parent class and subclass.

Lines connected through a circle connect the subclasses HourlyEmployee and SalaryEmployee to the superclass Employee. The circled letter "d" stands for disjointness, which demands that the specification's subclasses be distinct. As a result, an entity can belong to only one of the specification's subclasses. An individual employee can only be paid either hourly wages or a salary; they cannot be paid both. The open sides of the inheritance (arch) symbols face the superclass.

To know more about subclass click on the link:

brainly.com/question/13790787

#SPJ4

6 0
1 year ago
Other questions:
  • Jameis is researching at his local library when he finds a perfect source to use in his paper. When he goes to check the book ou
    12·2 answers
  • What's the fastest way to reset Android pin?​
    5·1 answer
  • What is the type of account and normal balance of allowance for uncollectible accounts?
    13·2 answers
  • A program to add two numbers in C++
    15·1 answer
  • How many rows and columns does ms-excel 2007 have???
    10·1 answer
  • 3. If the typical balance on Lucy's credit card is $750 and the interest rate (APR) on her credit card is 16%, how much in inter
    11·2 answers
  • Because public key encryption requires the use of two different keys, it is also known as _____ encryption
    13·1 answer
  • What is Administrator windows 10
    8·1 answer
  • Which is the correct option?
    6·1 answer
  • computer is an electronic machine that is used for data processing to produce meaningful information explain in statement​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!