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 multi-threaded program that outputs prime numbers. The program should work as follows: the user will run the program and
Ierofanga [76]

Answer:

The programming code can be found in the explanation part, please go through it.

Explanation:

Code:

#include<stdio.h>

#include<stdlib.h>

#include <pthread.h>

// function check whether a number

// is prime or not

int isPrime(int n)

{

// Corner case

if (n <= 1)

return 0;

// Check from 2 to n-1

for (int i = 2; i < n; i++)

if (n % i == 0)

return 0;

return 1;

}

void* printPrimes(void *vargp)

{

int *n = (int *)vargp;

int i=0;

for (i=2;i<=n;i++)

{

if (isPrime(i)) printf("%d\n", i);

}

}

// Driver Program

int main(int argc, char* argv[])

{

int n = atoi(argv[1]);

pthread_t tid;

pthread_create(&tid, NULL, printPrimes, (void *)n);

pthread_exit(NULL);

return 0;

}

4 0
3 years ago
Help me with ic3!!!!!!!
Scilla [17]

1. Locally 2. Codec 3. Analog, Digital 4. ISP 5.

4 0
3 years ago
Part of the operating system core is responsible for controlling security, managing the file system, and providing a platform fo
sasho [114]

Answer:

Kernel.

Explanation:

An operating system platform is a system software pre-installed on a computing device to manage or control software application, computer hardware and user processes.

This ultimately implies that, an operating system (OS) is essentially an interface between the computer’s hardware and all the software applications (programs) running on it.

Some examples of an operating system are QNX, Linux, OpenVMS, MacOS, Microsoft windows, IBM, Solaris, VM, etc.

Kernel is part of the operating system core. It is responsible for controlling security, managing the file system, and providing a platform for applications to run on.

Basically, the kernel is the foundational or fundamental layer of the operating system (OS) and as such it is loaded into memory whenever the computer system starts to boot i.e the kernel must always reside in the memory of a computer because it is saddled with the responsibility of managing computer resources such as the central processing unit (CPU), peripheral devices, random access memory (RAM) and input/output instructions from software programs.

3 0
3 years ago
Which is an example of a crime that might occur in an e-commerce transaction?
Zolol [24]

Answer:

A costumers credit card information is stolen and used by someone else.

6 0
3 years ago
Read 2 more answers
This is my paragraph . The type of color is ude in this code line is ..............................
ollegr [7]
What is the paragraph even supposed to be about
8 0
3 years ago
Other questions:
  • In evaluating the precedence rules used by Python, what statement is accurate? a. Addition and subtraction are evaluated after a
    8·2 answers
  • How does the text recommend that a company operate if it wants to be successful in the information age?
    11·1 answer
  • What is Human Dignity
    12·1 answer
  • What is the job title of someone who works with video and/or film?
    9·1 answer
  • 2. Who created the first photograph? How was this done?
    14·2 answers
  • Which lighting direction is used to create silhouettes
    15·1 answer
  • PLEASE HELP there are TWO ANSWERS
    6·1 answer
  • Which of the following expressions is not equivalent to X ' ?
    14·1 answer
  • What is the purpose of memory address?​
    9·2 answers
  • Which of the following declares an abstract method in an abstract Java class?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!