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
Write a program to Test if mold is stored in the variable word.
Aloiza [94]

word = whatever value you want.

if "mold" in word:

   print("Mold is in the variable word.")

else:

   print("Mold is not in the variable word.")

7 0
3 years ago
A(n ____________ is considered a named collection of bytes having persistent or lasting storage.
kykrilka [37]
A(n) file is considered a named collection of bytes having persistent or lasting storage.
6 0
3 years ago
In UML behavioral modeling, a message is _____. (Points : 6) a named location in memory where information is deposited and retri
rusak2 [61]

Answer: a function or procedure call from one object to another object

Explanation: UML(Unified Modeling language) behavioral modeling is the depiction of the relation of the elements in a dynamic manner and the dependency on time .Message in the UML behavioral modeling is a functional call taking place from one element to another.

The interaction is the model is seen through the flow of messages.Other options are incorrect because message is not information holding data structure, does not display the relation between object rather presents the flow and is not a memory location .

7 0
3 years ago
The diagram shows the positions of the Sun, Earth, and Moon during each moon phase. When viewed from Earth, at what point does t
goldfiish [28.3K]

Answer:

B

Explanation:

when it is on the same side of Earth as the Sun because it appears all black because of the shadow

7 0
2 years ago
Bill's manager has asked him to send all staff members the directions for checking out the new projector. In 1–2 sentences, desc
Alex787 [66]

He should send an email to all of his colleagues to inform them of all of the directions. Emails are an easy and fast route to letting people know what's up.

- Mabel <3

6 0
3 years ago
Read 2 more answers
Other questions:
  • I need help please?!!!!!!!!!
    15·1 answer
  • Which word most likely means "a timepiece fitted with a recording device that marks down exact intervals of time"? chronograph c
    9·2 answers
  • Henry has created a software that manages a database of all his music.he wishes to run the software on another computer system t
    5·1 answer
  • Kendra is taking a class in Finance and she has been asked to give a speech about a case study in which she's been working. She
    5·1 answer
  • Write the method addItemToStock to add an item into the grocery stock array. The method will: • Insert the item with itemName ad
    12·1 answer
  • Which set of symbols encloses an if-then code block? Choose the best answer.
    10·1 answer
  • 30 pts!<br> Explain how Moore's law presumes everyone will have access to the Internet.
    14·1 answer
  • Why does my wifi keep disconnecting and reconnecting?
    9·1 answer
  • Which computer language uses short words known as mnemonics for writing programs?
    14·1 answer
  • A student who wants to work with computers but does not have a strong aptitude for math might find a good fit by pursuing a(n)__
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!