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 does it mean when your check engine light comes on?
Ludmilka [50]
This website has an article about the on-board diagnostics system (OBD system) which turns on the Check Engine light in a motorized vehicle: https://motorist.org/articles/check-engine-light

Hope it helps you!
5 0
3 years ago
Cloud suites are stored on your hard drive and are available anywhere you can access the Internet
puteri [66]
Is that a question or an answer... im confused?!?!

5 0
2 years ago
What is the binary number 0011 0011 multiplied by two?
Nimfa-mama [501]

Answer:

1100110

Explanation:

0011 0011 = 51

51 x 2 = 102

5 0
3 years ago
Wow that funny a heck
lorasvet [3.4K]

Answer:

Seriously??? Omg - Orange Trump!!

3 0
2 years ago
i see tabs named mowed and Ramsey i tried shredding them and deleting them and ending all the processes but they start duplicati
VikaD [51]

1.Select the data.

2.Go to Data –> Data Tools –> Remove Duplicates.

3.In the Remove Duplicates dialog box: If your data has headers, make sure the 'My data has headers' option is checked. Make sure the column is selected (in this case there is only one column).

4 0
3 years ago
Other questions:
  • Which shortcut key combination will move the cursor to the beginning of the line
    10·1 answer
  • 2. What are the pros and cons of Toyota structure?
    13·1 answer
  • In Florida no fault insurance is optional for owners of a vehicle
    6·1 answer
  • IBF Consultants, LLC provides consulting services in privacy and theft deterrence solutions. Another client has very sensitive d
    7·1 answer
  • Which best describes the relationship between maximum cost-per-click (max. cpc) bids and ad rank?
    12·1 answer
  • 2.27 LAB: Driving costs Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as
    14·2 answers
  • Which statement uses the example type of context clue for the underlined word?
    5·2 answers
  • What does a hanging indent look like?
    7·1 answer
  • GRAND THEFT AUTO 5 LOLLL
    15·2 answers
  • To read encrypted data, the recipient must decipher it into a readable form. What is the term for this process?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!