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
Write pseudo code that performs the following: Ask a user to enter a number. If the
CaHeK987 [17]
Answer:
BEGIN
INPUT N
IF N>0 AND N<10 THEN
OUTPUT "blue"
ELSE
IF N>10 AND N<20 THEN
OUTPUT "red"
ELSE
IF N>20 AND N<30 THEN
OUTPUT "green"
ELSE
OUTPUT "It is not a correct color option"
ENDIF
END.

Explanation:

3 0
2 years ago
A hacker using information gathered from sniffing network traffic uses your banking credentials from a recent transaction to cre
adell [148]

Answer: a replay attack, a replay attack is used so that the attacker can go sniff out the hash, and get whatever they are trying to get, then once it goes to the attacker it will go back to the original connection after replaying the hash

3 0
2 years ago
Which of the following is an example of an application software?
pishuonlain [190]
Word processing software
6 0
2 years ago
Did this technological advancement take away or create jobs? Overall, what was the contribution of this technological advancemen
mars1129 [50]
It took away jobs and made day to day tasks easier
3 0
3 years ago
In a java class, variables can be present both inside and outside of methods. question 9 options:
Tems11 [23]
The correct answer is: True

Explanation:

Consider the following program:
<span>class Main {
int a = 10;
public static void main(String[] args) {
add();
}

private static void add() {
int b = a+20;
System.out.println(b);
}<span>
}


The output of the above program is 30. As you can see the variable a is declared outside the method, whereas variable b is declared inside the method.</span></span>
3 0
3 years ago
Other questions:
  • Which type of object is used to organize and store data in Microsoft access 2013
    5·2 answers
  • ou work as network administrator for an organization that has a Windows-based network. You want to use multiple security counter
    10·1 answer
  • Which of the following events would most likely produce an earthquake
    7·1 answer
  • A _____ is a harmful program that resides in the active memory of a computer and duplicates itself. Select one: a. scareware b.
    7·1 answer
  • A. Calculate the diffusion coefficient for magnesium in aluminum at 450°C.
    14·1 answer
  • The Office ____ is a temporary storage area. Warehouse Clipboard Storehouse Gallery
    15·1 answer
  • When clients connect to a web server using the _________ method, the server logs them on using the iusr account, by default?
    14·1 answer
  • HELP FAST PLS<br> Do you care more about avoiding fees/costs, accumulating perks, convenience, etc?
    14·2 answers
  • An embedded system describes computing technology that has been enclosed in protective shielding for security reasons. True or f
    12·1 answer
  • What are some of the most common obstacles in video games?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!