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
adelina 88 [10]
3 years ago
8

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

play 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. Then, create another array that store 5 integers. Pass the two arrays to a method that will display the integer value(s), if any, that appear in both arrays (note that the two arrays can have no stored values in common). Save the file as ArrayMethodDemo.java.
Computers and Technology
1 answer:
tensa zangetsu [6.8K]3 years ago
3 0

Answer:

  1.     public class Main {
  2.    public static void main(String[] args) {
  3.        int myArray[] = {3, 7, 2, 5, 9,11, 24, 6, 10, 12};
  4.        int myArray2 [] = {1, 2, 3, 4 ,5};
  5.        displayValue(myArray);
  6.        reverseDisplay(myArray);
  7.        displaySum(myArray);
  8.        displayLess(myArray, 10);
  9.        displayHighAvg(myArray);
  10.        displayBoth(myArray, myArray2);
  11.    }
  12.    public static void displayValue(int arr[]){
  13.        for(int i = 0; i < arr.length; i++){
  14.            System.out.print(arr[i] + " ");
  15.        }
  16.        System.out.println();
  17.    }
  18.    public static void reverseDisplay(int arr[]){
  19.        for(int i = arr.length-1; i >= 0; i--){
  20.            System.out.print(arr[i] + " ");
  21.        }
  22.        System.out.println();
  23.    }
  24.    public static void displaySum(int arr[]){
  25.        int sum = 0;
  26.        for(int i = 0; i < arr.length; i++){
  27.            sum += arr[i];
  28.        }
  29.        System.out.println(sum);
  30.    }
  31.    public static void displayLess(int arr[], int limit){
  32.        for(int i = 0; i < arr.length; i++){
  33.            if(arr[i] < limit){
  34.                System.out.print(arr[i] + " ");
  35.            }
  36.        }
  37.        System.out.println();
  38.    }
  39.    public static void displayHighAvg(int arr[]){
  40.        int sum = 0;
  41.        for(int i = 0; i < arr.length; i++){
  42.            sum += arr[i];
  43.        }
  44.        double avg = sum / arr.length;
  45.        for(int i = 0; i < arr.length; i++){
  46.            if(arr[i] > avg){
  47.                System.out.print(arr[i] + " ");
  48.            }
  49.        }
  50.        System.out.println();
  51.    }
  52.    public static void displayBoth(int arr1[], int arr2 []){
  53.        for(int i = 0; i < arr2.length; i++){
  54.            for(int j = 0; j < arr1.length; j++){
  55.                if(arr1[j] == arr2[i]){
  56.                    System.out.print(arr1[j] + " ");
  57.                }
  58.            }
  59.        }
  60.        System.out.println();
  61.    }
  62. }

Explanation:

There are five methods written to solve all the problems stated in the question.

Method 1 : displayValue    (Line 15 - 21)

This is the method that take one input array and use the print() method to display the all the elements in the array.

Method 2: reverseDisplay (Line 23 - 26)

This method will take one input array and print the value in the reverse order. We just need to start with the last index when running the for-loop to print the value.

Method 3: displaySum (Line 31 - 37)

This method will take one input array and use a for-loop to calculate the total of the values in the array.

Method 4: displayLess (Line 39 - 47)

This method will take one two inputs, a array and a limit. We use the limit as the condition to check if any value less than the limit, then the value will only be printed.

Method 5: displayHighAvg (Line 50 - 64)

This method will take one input array and calculate the average. The average will be used to check if any element in the array higher than it, then the value will only be printed.

Method 6: displayBoth  (Line 66 - 75)

This method will take two input arrays and compare both of them to find out if any value appears in both input arrays and print it out.

You might be interested in
The valid call to the function installApplication is
Zanzabum

Answer:

B. installApplication(‘A’, 1);

Explanation:

Given

The above code segment

Required

The correct call to installApplication

The function installApplication is declared as void, meaning that it is not expected to return anything.

Also, it receives a character and an integer argument.

So, the call to this function must include a character and an integer argument, in that order.

Option D is incorrect because both arguments are integer

Option C is incorrect because it passes no argument to the function.

Option A is incorrect because it receives an integer value from the function (and the function is not meant not to have a return value).

Option B is correct

8 0
3 years ago
Jean has created a database to track all of this month’s family meals. To find an entry for lasagna, what would should Jean do?
Nutka1998 [239]
A or d


A edit data

And
.
,
D sort of data
6 0
3 years ago
A centralized structure does not provide information from local stores that would be useful in changing its technology quickly.
mylen [45]
<span>The statement that "A centralized structure does not provide information from local stores that would be useful in changing its technology quickly is an example that illustrates the effect of structure on strategy" is true. 
</span><span> Changes in the external environment are the reason why changes in the technology and emergence of dynamic technological advancements should be done.</span>
7 0
4 years ago
PLEASE HELP THIS WAS DUE YESTERDAY AND I DIDN'T GET TO IT IN TIME!!!!!!
kykrilka [37]

Answer:

dDAgv

Explanation:

sdc sdc sdc trust me

7 0
3 years ago
What are the factors affecting the life of ballast? Explain.​
Nady [450]

Answer:

When it's too hot or too cold.

Explanation:

When a bulb of the wrong size or voltage is used in the fixture, the ballast often overheats, causing the light to shut off. The bulbs and the fixture must also match in frequency, or the ballast becomes overworked and overheated.

7 0
3 years ago
Other questions:
  • Which setting indents all but the first line of a paragraph by the selected length?
    6·1 answer
  • Spreadsheet software creates a ____, composed of a grid of columns and rows
    6·1 answer
  • The ____ function sums the numbers in the specified range and then divides the sum by the number of cells with numeric values in
    14·1 answer
  • Enzo formed a study group for an upcoming geography test. To start off each session, they go over past notes and look at maps. T
    14·1 answer
  • Replmon is the first tool you should use when troubleshooting Active Directory replication issues. State True or False.
    12·1 answer
  • a corporation needs an operating system that allows the various teams in its office to network &amp; collaborate on projects. wh
    11·2 answers
  • All computers perform disk optimization utilizing the same software.<br><br> true <br> false
    11·1 answer
  • I CANT DO SKIN MODS ON BRAWLHALLA RIGHT!!!! IM SO MADDDDDDDDDDD
    11·1 answer
  • Choose all items that represent examples of good website accessibility.
    8·2 answers
  • c++ 4.17 LAB: Count characters Write a program whose input is a character and a string, and whose output indicates the number of
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!