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
True or false? Resistors regulate and limit electrical current. A. True B. False
Vikki [24]
Hello! I believe the answer for this is "True"!
3 0
3 years ago
Read 2 more answers
When a computer or digital device is used as a storage device or in the facilitation of an offense, it is argued to be ____ to t
Katen [24]

Answer:

Incidental.

Explanation:

When a computer or digital device is used as a storage device or in the facilitation of an offense, it is argued to be incidental to the offense.

For instance, the list of customers used by human traffickers is considered to be generated through an incidental system.

8 0
2 years ago
How do I change my username/display name
exis [7]

Answer:

.

Explanation:

you do to me on the bottom bar and once you hit that you click the pencil and change it

6 0
3 years ago
Read 2 more answers
The ________ simulates your work area.
xz_007 [3.2K]
I believe it is, A. taskbar
5 0
3 years ago
Create and apply a CSS class named YellowBackground that selects a yellow background. Apply the class to your HTML file’s body t
masha68 [24]

Here is an HTML example with the CSS class defined inline:

<!doctype html>

<html>

 <head>

   <style>

  .YellowBackground {

 background-color : yellow;

  }

</style>

   

   </head>

 

   <body class="YellowBackground">

       <h1>A yellow background</h1>

   </body>

</html>

6 0
3 years ago
Other questions:
  • What is the chief ethical concern concerning all the new sources of data available through new technological means like internet
    9·1 answer
  • HELP PLEASE NOW ASAP BRAINLIEST
    13·2 answers
  • What is the most common password on the internet?
    11·2 answers
  • Which type of cloud computing offers easily accessible software and applications on the machines?
    7·1 answer
  • Does anyone know where online I can buy the MacBook Air 2017 at I can’t find any I’ll give brainlist and points
    5·1 answer
  • Public class Main{ public static void main(String [] args){ String name=WelcomeJava; Runnable r1=() -&gt; System.out.println(nam
    12·1 answer
  • a farmer cultivates 1/4 of his farm with ground nuts and 2/5 of it with maize what is the total landnarea that is cultivated​
    12·1 answer
  • What is the purpose of a hyperlink in a presentation?
    11·1 answer
  • ) Printers today have many features that include improved quality, photo printing capabilities, digital camera connectivity, bui
    11·1 answer
  • What type of natural disaster stuck haiti in 2010 and killed more than 200,000 people
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!