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
lara31 [8.8K]
3 years ago
13

Write a function addOddMinusEven that takes two integers indicating the starting point and the end point. Then calculate the sum

of all the odd integers minus the sum of all even integers between the two points. The calculation includes the starting point but excludes the end point. You can always assume the starting point is smaller than the end point.
Computers and Technology
1 answer:
snow_lady [41]3 years ago
8 0

Answer:g

   public static int addOddMinusEven(int start, int end){

       int odd =0;

       int even = 0;

       for(int i =start; i<end; i++){

           if(i%2==0){

               even = even+i;

           }

           else{

               odd = odd+i;

           }

       }

       return odd-even;

   }

}

Explanation:

Using Java programming language:

  • The method addOddMinusEven() is created to accept two parameters of ints start and end
  • Using a for loop statement we iterate from start to end but not including end
  • Using a modulos operator we check for even and odds
  • The method then returns odd-even
  • See below a complete method with a call to the method addOddMinusEven()

public class num13 {

   public static void main(String[] args) {

       int start = 2;

       int stop = 10;

       System.out.println(addOddMinusEven(start,stop));

   }

   public static int addOddMinusEven(int start, int end){

       int odd =0;

       int even = 0;

       for(int i =start; i<end; i++){

           if(i%2==0){

               even = even+i;

           }

           else{

               odd = odd+i;

           }

       }

       return odd-even;

   }

}

You might be interested in
HELP ASAP
Tju [1.3M]

Answer: B. Personal Idea

Explanation:

Issac Newton's Law of Gravity was made by the one and only, Issac Newton.

He used his time to investigate and discover this law, so choice one, cheating is not correct. Choice three is also incorrect, because the world didn't know about this law, or so much about gravity during that time.

Thus, choice two is correct because it was created and written through his ideas.

So therefore, the answer is choice two, personal idea.

Read more on Brainly.com - brainly.com/question/10659333#readmore

4 0
3 years ago
I wiil mark brainlist ​
Darina [25.2K]
CAD is the answer you require, but it may also be Spread sheet

Hope this helped ♥︎
5 0
3 years ago
Which best describes what databases do?
quester [9]

Answer:

They create categories for data.

Explanation:

They can create categories for data, by storing the data. Information itself can be stored in multiple ways, like creating categories!

I hope this helped :)

6 0
3 years ago
Read 2 more answers
What does ;-; mean during a text?
zzz [600]

Answer:

Its like an emotionless crying face, mainly used for humor

Explanation:

5 0
3 years ago
Read 2 more answers
The security administrator of ABC needs to permit Internet traffic in the host 10.0.0.2 and UDP traffic in the host 10.0.0.3. Al
koban [17]

Answer:

The correct selection is the letter C. The first ACL is denying all TCP traffic and the other ACLs are being ignored by the router.

Explanation:

In this case, the letter C is the right answer because with the first ACL exactly:

access-list 102 deny tcp any any

We are denying all traffic with the next line deny tcp any any, in this case, the others line are being ignored.

access-list 104 permit udp host 10.0.0.3 any

access-list 110 permit tcp host 10.0.0.2 eq www any

access-list 108 permit tcp any eq ftp any

For that nobody can access to the internet, the security administrator of ABC must change the first ACL.

5 0
3 years ago
Other questions:
  • Write a program that produces a Caesar cipher of a given message string. A Caesar cipher is formed by rotating each letter of a
    14·1 answer
  • Give me give me keyboard on this phone please provide nice I can't type where is the keyboard.Give me give me keyboard on this p
    6·2 answers
  • Changes in computer technology have an effect on _____.
    13·1 answer
  • Convert the binary number into a hexadecimal number.
    7·1 answer
  • Why are ethics important in PR?
    8·1 answer
  • What is a credit card balance? A...The amount of interest you must pay the credit card company B...The required minimum payment
    15·1 answer
  • Having data in a column formatted differently based on value is known as
    7·1 answer
  • What would happen if computers only had input devices?
    9·1 answer
  • Create a PHP page that contains an array of at least 20 movie titles or book titles (your choice). The HTML page should have an
    7·1 answer
  • palindrome is a string that reads the same forwards as backwards. Using only a xed number of stacks, and a xed number of int and
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!