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
Everyone’s favorite speedy blue hedgehog recently returned to his 2D origins in a critically acclaimed side-scrolling game. What
forsale [732]
It was called sonic mania
3 0
3 years ago
Read 2 more answers
Can someone help me calculate this Multimedia math:
IRISSAK [1]

Answer:

I will try to help you answer this. it seems really confusing but I'll do my best to solve it and get it back to you. Hope I'm able to help!

5 0
3 years ago
What is an embedded system. Give examples
IRINA_888 [86]

Answer:

An embedded system is a part of a larger system which has either one or a limited number of dedicated functions.

It doesn't require much power to run and is cheap to make and design.

Explanation:

Examples include: cars, microwaves, traffic lights, washing machines, phones etc

6 0
3 years ago
Write a program that creates a dictionary containing the U.S. states as keys and their abbreviations as values. The program shou
AleksandrR [38]

Answer:

Explanation:

The following program is written in Python. It creates a loop that keeps creating a random number to randomly choose a State abbreviation from the dictionary. Then it asks the user what the state is. If the user gets the answer correct it prints out "Correct" and adds 1 point to the correct variables. Otherwise it prints "Incorrect" and adds 1 point to the incorrect variable. Finally, printing out the final amount of correct and incorrect responses. The program was tested and the output can be seen below.

import random

states = {"AL":"Alabama","AK":"Alaska","AZ":"Arizona","AR":"Arkansas","CA":"California","CO":"Colorado","CT":"Connecticut","DE":"Delaware","FL":"Florida","GA":"Georgia","HI":"Hawaii","ID":"Idaho","IL":"Illinois","IN":"Indiana","IA":"Iowa","KS":"Kansas","KY":"Kentucky","LA":"Louisiana","ME":"Maine","MD":"Maryland","MA":"Massachusetts","MI":"Michigan","MN":"Minnesota","MS":"Mississippi","MO":"Missouri","MT":"Montana","NE":"Nebraska","NV":"Nevada","NH":"New Hampshire","NJ":"New Jersey","NM":"New Mexico","NY":"New York","NC":"North Carolina","ND":"North Dakota","OH":"Ohio","OK":"Oklahoma","OR":"Oregon","PA":"Pennsylvania","RI":"Rhode Island","SC":"South Carolina","SD":"South Dakota","TN":"Tennessee","TX":"Texas","UT":"Utah","VT":"Vermont","VA":"Virginia","WA":"Washington","WV":"West Virginia","WI":"Wisconsin","WY":"Wyoming"}

keys_list = list(states)

correct = 0

incorrect = 0

while True:

   randNum = random.randint(0, 49)

   abbr = keys_list[randNum]

   answer = input("Enter The State name of " + abbr + ": ")

   if answer.lower() == states[abbr].lower():

       print("Correct")

       correct += 1

   else:

       print("Incorrect")

       incorrect += 1

   again = input("Play again? y/n ")

   if again.lower() == 'n':

       break

print("Correct: " + str(correct))

print("Incorrect: " + str(incorrect))

6 0
2 years ago
010101010101011101011
sattari [20]
Whatwhatwhatwhat???????????
6 0
3 years ago
Other questions:
  • How to reset your password if you changed your email and dont remember password?
    6·1 answer
  • Which is a characteristic of an effective problem statement? It is based on research. It contains outside information. It contai
    12·1 answer
  • #include &lt;iostream&gt;
    9·1 answer
  • Fill in the blank with the letter HTML
    14·1 answer
  • Consider the packets exchanged in TCP connection setup between Host A and Host B. Assume that Host A's initial sequence number i
    7·1 answer
  • The loop function is similar to range(), but handles the parameters somewhat differently: it takes in 3 parameters: the starting
    14·1 answer
  • What component uses thermal paste to attach the heat sink?
    13·1 answer
  • Factoring of integers. Write a python program that asks the user for an integer and then prints out all its factors. For example
    13·1 answer
  • 13. By adding built-in writable memory to its cartridge, Nintendo’s _________________ was the first console game that gamers cou
    9·1 answer
  • I have no idea how to use the sep and end in Python can someone help me I have a test tomorrow
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!