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
lapo4ka [179]
3 years ago
13

Write a method that take an integer array as a parameter and returns the sum of positive odd numbers and sum of positive even nu

mbers.
Computers and Technology
1 answer:
elixir [45]3 years ago
6 0

Answer:

I will code in Javascript:

function sumOddAndEven(){

<em> //Define and initialize variables.</em>

var numbers = [1,2,3,4,5,6,7,8];

var sum = [0,0];

for ( var i = 0;  i < numbers.length ; i++ ){  <em>// loop to go throght the numbers</em>

<em> </em>if(numbers[i] > 0) {<em> // if the number is positive</em>

  if(numbers[i]%2 == 0) {  <em>// if number is even and </em>

     sum[0] = sum[0] + numbers[i];  <em>//adds in the first place of sum</em>

   }

   else{  

     sum[1] = sum[1] + numbers[i];  <em>// else adds in the second place of sum</em>

   }

 }

}

 return sum; <em>//return an array with the sum of the positive evens numbers  in the first place and the sum of the positive odd numbers in the second place.</em>

}  

You might be interested in
The Windows taskbar is generally found _____. at the top of the screen in the Start menu at the bottom of the screen at the righ
rjkz [21]
At the bottom of the screen.
4 0
3 years ago
Read 2 more answers
Given: an int variable k, an int array current Members that has been declared and initialized, an int variable memberID that has
Alekssandra [29.7K]

Answer:

The c++ program is given below. Nothing is displayed as per the question.

#include <iostream>

using namespace std;

int main() {    

   // declaration and initialization of integer variables

   int k, memberID = 12, nMembers=5;

   bool isAMember;    

   // declaration and initialization of integer array

   int currentMembers[] = {12, 34, 56, 78, 90};    

   for(k=0; k<nMembers; k++)

   {

       if(memberID == currentMembers[k])

       {

           // when member is found in the array, the loop is exited using break

           isAMember = true;

           break;

       }

       else

           isAMember = false;

   }    

   return 0;

}

Explanation:

The program begins with declaration and initialization of integer variables and followed by initialization of the array holding the id of all the members.

The Boolean variable is declared but not initialized.

int k, memberID = 12, nMembers=5;

bool isAMember;

int currentMembers[] = {12, 34, 56, 78, 90};

After this, the array holding the id of the members is searched for the given member id. This is done using  a for loop and a if else statement inside the loop.

If the member id is present in the array, the variable isAMember is initialized to true otherwise it is assigned false.

When the variable isAMember is initialized to true, the break statement is used to exit from the loop.

for(k=0; k<nMembers; k++)

   {

       if(memberID == currentMembers[k])

       {

           isAMember = true;

           break;

       }

       else

           isAMember = false;

 }

The break is used since other values of id in the array will not match the given member id and the variable, isAMember will be initialized to false even if the given member id is present in the array. Hence, it is mandatory to exit the loop once the given member id is found in the array.

This program can be tested for different values of the id of the members and different sizes of the array.

4 0
3 years ago
Create a horizontal line across middle of the entire form. To code this the ____ values are the same.
fredd [130]

To make a horizontal line in mathematics you require some sort of constant function. Where no matter the input x the output y will always equal to a certain number n.

For eg. consider n = 2. Hence the graph of line has an equation of y = n making it always intercept in (x, n). As x increases the y is the same therefore the horizontal infinite line emerges.

So to plot or code this kind of program you need to have the same values of y therefore y is a constant function.

Hope this helps.

r3t40

5 0
3 years ago
Read 2 more answers
An asymmetric encryption system utilizes how many keys?
ivanzaharov [21]
Two. One for encryption, and one for decryption. RSA is an example of an asymmetric encryption algorithm.
7 0
3 years ago
Question 15 of 25
GaryK [48]
It gains purchasing power. Less money in circulation = more value.
5 0
2 years ago
Other questions:
  • Melissa and Sue want to show a presentation to twenty employees using a presentation while using a projector. They learn that th
    12·2 answers
  • Microsoft access does not create n:m relationships because microsoft access creates databases based on
    7·1 answer
  • (1) In Tamara's science class, the students are learning Which sentence shows an action that is extrinsically
    7·1 answer
  • What problem with internal hardware components is similar to unplugged
    6·2 answers
  • What is the basic difference between a printer and a plotter?​
    12·1 answer
  • . Identify an emerging crime issue in your community using data available from sources such as local newspapers, online police r
    6·1 answer
  • Eye wash stations should contain enough water to provide ______ minutes of continuous use
    5·2 answers
  • identify at least three additional ethical responsibilities expected from a computer professional. In brief, explain each respon
    11·1 answer
  • The components of hardware include:
    6·2 answers
  • Is an electronics standard that allows different kinds of electronic instruments to
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!