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
A field whose data type is ____ can store text that can be used as a hyperlink address
olya-2409 [2.1K]
A field whose data type is URL address data can store text that can be used as a hyperlink address.
8 0
3 years ago
What is up with the bots? They are so annoying.
Yuki888 [10]

Answer:

very very very annoying

6 0
2 years ago
Read 2 more answers
Select the correct answer. Which input device uses optical technology?
daser333 [38]

Answer:

barcode reader is the correct answer

8 0
3 years ago
Define the term editing​
Harrizon [31]

Answer:

editing is a word file mean making changes in the text contain is a file. or a word file is one of the most basic ms office word operation.

8 0
3 years ago
Write a MATLAB script m-file to compute the ISS given an array of 6 AIS scores, which represent the most severe injuries to each
Dmitrij [34]

Answer:

The Matlab code is as given in the explanation, paste the code in the new script file, save it and run.

Explanation:

The code is as follows

Code:

<em>%% Initialization of the code</em>

<em>% The code takes an array of six AIS scores of the form [AIS1 AIS2 AIS3</em>

<em>% AIS4 AIS5 AIS6] of order 1x6.</em>

<em>AIS=input('Please enter the AIS array of the form [AIS1 AIS2 AIS3 AIS4 AIS5 AIS6]');%taking input of the array</em>

<em>AISs=sort(AIS,'descend');%sorting the array in the descending order</em>

<em>iss=(AISs(1,1)^2)+(AISs(1,2)^2)+(AISs(1,3)^2);%Calculating the ISS</em>

<em>disp(['The injury severity score (ISS) for the entered array is ', num2str(iss)])%Displaying the output</em>

Output:

<u><em>Please enter the AIS array of the form [AIS1 AIS2 AIS3 AIS4 AIS5 AIS6][3 0 4 5 3 0];</em></u>

<u><em>The injury severity score (ISS) for the entered array is 50</em></u>

<u><em /></u>

4 0
3 years ago
Other questions:
  • What is the most credible website or webpage you have ever visited?Why is it so credible? Describe some of the qualities that ma
    11·1 answer
  • Universal Containers is tracking the interviewer's ratings of candidate in Salesforce. They would like to easily link the Candid
    5·1 answer
  • Create a structure named planet This structure will contain distance from Earth as an integer Atmosphere, language, people and p
    8·1 answer
  • What needs to be increased in order to increase image size and clarity?
    10·1 answer
  • Csc105 final graded project
    9·1 answer
  • How can a signature be added to an email message? Check all that apply.
    10·2 answers
  • Which option describes wearable technology?
    9·1 answer
  • Which is the OS that can be obtained for free or at a much lower price than other major operating systems?
    15·2 answers
  • A ______ is a group of slides designed and formatted for a specific purpose. These include themes as well as content.
    8·1 answer
  • Lasses give programmers the ability to define their own types. <br><br> a. True<br> b. False
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!