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

Write a method, including the method header, that will receive an array of integers and will return the average of all the integ

ers. Be sure to use the return statement as the last statement in the method. A method that receives an array as a parameter should define the data type and the name of the array with brackets, but not indicate the size of the array in the parameter. A method that returns the average value should have double as the return type, and not void. For example: public static returnType methodName(dataType arrayName[]) 3 The array being passed as a parameter to the method will have 10 integer numbers, ranging from 1 to 50. The average, avgNum, should be both printed in the method, and then returned by the method. To print a double with 2 decimal points precision, so use the following code to format the output: System.out.printf("The average of all 10 numbers is %.2f\n", avgNum);
Computers and Technology
1 answer:
Burka [1]3 years ago
6 0

Answer:

The method is as follows:

public static double average(int [] arrs){

    double sum = 0,avgNum;

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

        sum+=arrs[i];

    }

    avgNum = sum/arrs.length;

    System.out.printf("The average of all numbers is %.2f\n", avgNum);

    return avgNum;

}

Explanation:

This defines the method

public static double average(int [] arrs){

This declares sum and avgNum as double; sum is then initialized to 0

    double sum = 0,avgNum;

This iterates through the array

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

This adds up the array elements

        sum+=arrs[i];     }

This calculates the average

    avgNum = sum/arrs.length;

This prints the average to 2 decimal places

    System.out.printf("The average of all numbers is %.2f\n",

avgNum);

This returns the average to main

    return avgNum; }

You might be interested in
Intro to Computers quiz answers me need for test please help me hurry
RSB [31]

Answer:

Ethernet connection

Explanation:

4 0
3 years ago
Create a basic program that accomplishes the following requirements: Allows the user to input 2 number , a starting number x and
katrin [286]

Answer:

Explanation:

The following program is written in Java. It asks the user for the two inputs and then uses those inputs in a for loop. The loop goes through each number checking to see if it is even or odd. If it is even it prints out Even: and the number after multiplying it by 3. If it is odd it prints out Odd: and the number after adding 10 to it. The output can be seen in the attached picture below.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter number 1: ");

       int num1 = in.nextInt();

       System.out.println("Enter number 2:");

       int num2 = in.nextInt();

       for (int x = num1; x <= num2; x++) {

           if ((x % 2) == 0) {

               System.out.println("Even: " + (x*3));

           } else {

               System.out.println("Odd: " + (x+10));

           }

       }

   }  

}

6 0
3 years ago
Tim is a project manager. He is brainstorming with his team about problems that could arise during the next phase of the project
Grace [21]

Answer:

b.

Explanation:

just took the quiz

8 0
2 years ago
Imaging a computer is part of what phase of conversion?
grandymaker [24]
B. Because the computer can rearrange itself when it is in a phase of conversion
5 0
3 years ago
What are the different parts of a word processing program?<br><br> I need this ASAP please help!!
uranmaximum [27]

Answer:

The basics of the Word window

Title bar. This displays the document name, followed by a program name.

Menu bar. This contains a list of options to manage and customize documents.

Standard toolbar. ...

Formatting toolbar. ...

Ruler. ...

Insertion point. ...

End-of-document marker. ...

Help.

3 0
3 years ago
Other questions:
  • Match the following technologies with their applications.
    9·1 answer
  • Why is the DNS service included in Windows Server 2012 R2 integrated with DHCP service?
    6·1 answer
  • Consider the following page reference string:
    12·1 answer
  • Which of these shortcuts becomes available only when text is highlighted?
    10·1 answer
  • Which data type is 2.5?
    5·1 answer
  • Can anyone help and write a sample answer to this please x
    7·1 answer
  • Which of these is NOT an example of a GUI?
    7·1 answer
  • Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. T
    6·1 answer
  • In the graph shown here, by what percentage are the number of people in computer occupations in general projected to increase?
    10·2 answers
  • Add criteria to this query to return only the records where the value in the SubscriptionType field is Self or Family and the va
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!