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]
3 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]3 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
Alice just wrote a new app using Python. She tested her code and noticed some of her lines of code are out of order. Which princ
LenKa [72]

Answer:

This is Elijah from FLVS hihi :DDDDDDDDDDDDDDDDDDDDDDDDDDDDD CVS

Explanation:

6 0
3 years ago
How do i open screenshots on school chromebook?
yuradex [85]

Answer:

you have to open your file explorer and open the screenshot folder.

Explanation:

3 0
2 years ago
Read 2 more answers
What is the fastest typing speed ever recorded? Please be specific!
Alex

Answer:

250 wpm for almost an hour straight. This was recorded by Barbara Blackburn in 1946.

7 0
3 years ago
Inserting a new value in the middle of a singly lnked list requires changing the pinter of the list node that follows the new no
lukranit [14]

Answer:

A.) True

Explanation:

Inserting a new value in the middle of a singly lnked list requires changing the pinter of the list node that follows the new node.

8 0
3 years ago
One acre of land is equivalent to 43,560 square feet. Write a program that asks the user to enter the total square feet in a tra
lana [24]

Answer:

Explanation:

Using Python programming language:

def get_number_acres(square_feet):

   return square_feet / 43560

sq_feet = input('Enter the number of square feets >>> ')

number_acres = get_number_acres(sq_feet)

7 0
3 years ago
Other questions:
  • How many different messages can be transmitted in n microseconds using three different signals if one signal requires 1 microsec
    12·1 answer
  • Which unique address is a 128-bit address written in hexadecimal?
    13·1 answer
  • Clicking a _____ name opens a drop-down list of commands and options.
    6·1 answer
  • Me2540 week 5 assignment<br> what do i want to know?
    9·1 answer
  • What is the first document that colleges review when making admissions decisions
    10·2 answers
  • Which is true about POP3 and IMAP for incoming email?
    10·1 answer
  • For each recursive call, display the outputs on a separate line and add a level of indentation. do your utmost to make the outpu
    10·1 answer
  • personal digital assistants are handheld devices that serve as personql information managers. what is another term used to refer
    11·2 answers
  • Why is it important to install updates? Why should you use the Power button on the Start menu instead of the Power button on you
    7·1 answer
  • Computer operates nearly 100% accurately but why is the phrase'garbage in garbage out'(GIGO) associated with their use?Describe
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!