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
Anestetic [448]
2 years ago
8

1. Write a static method named computeOddSum that is passed an array of int's named numbers. The method must compute and return

the sum of all the values in numbers that are odd. For example, if numbers is {3, 10, 11, 2, 6, 9, 5} then the value 28 should be returned since 3 11 9 5
Computers and Technology
1 answer:
S_A_V [24]2 years ago
5 0

Answer:

The method in Java is as follows:

public static int computeOddSum(int [] myarray){

       int oddsum = 0;

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

        if(myarray[i]%2==1) {

           oddsum+=myarray[i];

        }

     }

     return oddsum;

   }

Explanation:

This defines the static method

public static int computeOddSum(int [] myarray){

This initializes oddsum to 0

       int oddsum = 0;

This iterates through the array

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

This checks for odd number

        if(myarray[i]%2==1) {

The odd numbers are added, here

           oddsum+=myarray[i];

        }

     }

This returns the calculated sum of odd numbers

     return oddsum;

   }

To call the method from main, use:

<em>int [] myarray = {3, 10, 11, 2, 6, 9, 5};</em>

<em>      System.out.println("Odd sum = " + computeOddSum(myarray));</em>

You might be interested in
What's wrong with SontungMTP's song?
Anettt [7]

Answer:

A

Explanation:

7 0
3 years ago
Read 2 more answers
Why are there more producers then consumers?​
Ivanshal [37]

Answer:

because producer can make their own food

6 0
3 years ago
Read 2 more answers
((GUITAR))<br> What is the letter name for the note shown above?<br><br> D<br> E<br> F<br> G
iren2701 [21]
It is Letter G
Explanation: Took Guitar classes as a kid and memorized the letters.
3 0
2 years ago
What is the influence of new technology on society?
sweet [91]

Answer:

E. New technology is beneficial but can also be used in a detrimental way.

Explanation:

New technology such as cryptocurrency (powered by blockchain technology) can be regarded as a welcome development that has benefited the society in so many good ways. However, cryptocurrency as a new technology also has disadvantages it presents to the society. One of such negative influence cryptocurrency has is that it can be used for illicit activities such as money laundering, funding terrorism and so on.

So, in summary, we can conclude that:

"New technology is beneficial but can also be used in a detrimental way."

5 0
2 years ago
IMPORTANT HELP
balu736 [363]

Answer:

plz am so sorry I don't no it

Explanation:

Plz give me brainiest

6 0
3 years ago
Other questions:
  • All of the nested folders you created will carry the same permissions as the __________ until you make changes.
    10·1 answer
  • What is the output of the following C++ program?
    15·1 answer
  • Evolution of computers
    13·2 answers
  • Which route of entry could chemicals use to enter through the body’s airways?
    8·1 answer
  • Analyze the following code. Which of the following statements is correct?
    9·1 answer
  • Peripeteia is also referred to as __________.
    5·2 answers
  • Gray London is a retired race car driver who helped Dale Earnhardt, Jr. get his start. He is writing a book and making a video a
    9·1 answer
  • Is jesus dead or alive
    11·1 answer
  • A company is acquiring a smaller firm and is setting up a new IT system in order to consolidate the data and assets of the acqui
    11·1 answer
  • Osing Commands
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!