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
Maurinko [17]
4 years ago
7

Create a Java static method named getAverageOfFours that takes an array of integers as a parameter and returns the average of th

e values in the array that are evenly divisible by 4. Your method must work for an int array of any size. Example: If the array contains [10, 48, 16, 99, 84, 85], the method would return 49.33333.
Computers and Technology
1 answer:
Zepler [3.9K]4 years ago
8 0

Answer:

public class average{

   

   public static float getAverageOfFours(int[] arr){

       

       int n = arr.length;

       float sum = 0;

       int count=0;

       for(int i=0;i<n;i++){

           if(arr[i]%4==0){

               sum = sum+arr[i];

               count++;

           }

       }

       float avg = sum/count;

       return avg;

       

   }

    public static void main(String []args){

       

        int[] array = {10, 48, 16, 99, 84, 85};

       

        float result = getAverageOfFours(array);

        System.out.println("The average is "+result);

    }

}

Explanation:

Create the function with one parameter and return type is float.

Declare the variable and store the size of array. Take a for loop for traversing in the array and and check the element is divisible by 4 or not by using if statement. If condition true take the sum and increment the count.

This process continue until the condition is true.

finally take the average and return it.

Create the main function for calling the function with pass the array as argument and also define the array.

After that print the result return by the function.

You might be interested in
Which categories format cells
fredd [130]
Currency, percentage, date, time, fraction, scientific
4 0
3 years ago
Read 2 more answers
1) It is possible to email a document<br> directly from the Word application.<br> O FALSE<br> O TRUE
QveST [7]

Answer:

True

Explanation:

8 0
3 years ago
What is a series of instructions or commands that a computer follows used to create software
kobusy [5.1K]
The series of instructions or commands that a computer follows used to create software is a Program
4 0
4 years ago
Which of the following is true about scalability?
blsea [12.9K]

Answer:

Option (i) is the correct answer to the following question.

Explanation:

Because to achieve the strong scaling then, we have required the Amdahl’s law and the scalability is the weak scaling that is easier to instate than the powerful scaling scalability because of only Amdahl’s law.

So, that's why the following option is correct.

Option (ii) is incorrect because usually, there no communication among the procedures.

Option (iii) is incorrect because the following option is not related to the following statement.

Option (iv) is incorrect because the dependency of the data or information is decreased.

4 0
3 years ago
At the frequency of 2.4 GHz what is the free-space path loss in dB.
chubhunter [2.5K]

Answer:

The FSBL is 100.05 dB

Solution:

As per the question:

Frequency, f = 2.4 GHz = 2.4\times 10^{9}

Now, we know that to calculate FSBL, i.e., Free Space Path Loss in dB, we use:

FSBL(in dB) = 10log_{10}(\frac{4\pifd}{c})^{2}

where

d = 1 km = 1000

c = 3\times 10^{8} m/s

FSBL(in dB) = 20log_{10}\frac{4\pifd}{c} = 20log_{10}(fd) + 20log_{10}(\frac{4\pi}{c})

FSBL(in dB) = 20log_{10}(f) + 20log_{10}(d) + 20log_{10}(\frac{4\pi}{c})

FSBL(in dB) = 20log_{10}(2.4\times 10^{9}) + 20log_{10}(10^{3}) + 20log_{10}(\frac{4\pi}{3\times 10^{8}})

FSBL(in dB) = 20\times 9.3802 + 20\times 3 - 147.55 = 100.05 dB

6 0
3 years ago
Other questions:
  • Which shortcut key aligns text to the center of a page?
    13·2 answers
  • What do you click on to minimize all open windows? the Show Desktop icon the Start menu the system tray the taskbar
    15·2 answers
  • What are the coordinates of (3 comma space 8 )relative to the basis open curly brackets space (1 comma space 1 )comma space (0 c
    15·1 answer
  • Write an algorithm to determine a students final grade and indicate whether it is passing or failing .the final grade is calcula
    12·1 answer
  • COMPUTER SCIENCE:PIXELS
    5·1 answer
  • Write a program that uses an initializer list to store the following set of numbers in an array named nums. Then, print the arra
    10·2 answers
  • What is meant by Information Retrieval?
    8·1 answer
  • What was the name of first computer?
    14·1 answer
  • Does any of yall play rob lox?
    5·2 answers
  • Given three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the absolut
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!