answer.
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]
2 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]2 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
vertical exchanges are typically used only to buy and sell materials required for an organization's support activities ( True or
torisob [31]

Answer:

Vertical exchanges are typically used only to buy and sell materials required for an organization's support activities- False

7 0
1 year ago
Read 2 more answers
A queueing system has four crews with three members each. The number of "servers" is:
pentagon [3]

Answer:

The answer is 4.

The number of active servers is four for this four crew queuing system.

Explanation:

 Now what is a queue management system?

As from the name it has some link with queue which means it’s not something used once or twice.

It is a continuous process. In simple words, the number of processes increases and the severs get short and congested on this type of problem this management occurs.

It is always there to solve the problem of congestion the system.

Queuing management is concerned with queuing areas. Where there will a queue this system will be applied. And this queuing system is based on queuing theory.

<u>Now what means by queuing areas? </u>

It’s a place where queues happen.

<u> But what exactly is a queue? </u>

You could say it’s a line of something waiting for services or you can also say it as an application of “demands exceed the supply” problem.

Now consider queuing system where the number of active servers depends upon the the length of the queue.

As the length of the queue increases the number of active servers will increase and if the length of the queue decreases the number of active servers decreases.

On traditional scale the queuing theory, the theory on which this queuing system is based, there are fixed number of servers for each model as 10,25 or 19 servers.  

Now if we see there is a queuing system has four crews with 3 members each.

Each crew will have its own one single active server so, there will be 4 active servers in this queuing system.

6 0
2 years ago
Read 2 more answers
A summer camp offers a morning session and an afternoon session.
defon

Answer:

(A) IF (IsFound

(afternoonList, child))

{

APPEND (lunchList, child)

}

Hope this helps!

5 0
2 years ago
Write a print statement that displays a random integer between 5 and 5000. Assume the random library is imported.
Contact [7]

Answer:

Explanation:

The following code is written in Java. It is a very simple three line statement (assuming that the random library was imported) that chooses a random integer value between 5 and 5000 and prints it to the screen using the println statement.

Random rand = new Random();

int randomNum = rand.nextInt((5000 - 5) + 1) + 5;

System.out.println(randomNum);

The random number generator is initialized and given a value between 5 and 5000. Since random number Generator will generate a number between 0 and the given value then subtracting 5 from the initial generated number makes sure that it is not more than 5000 and then adding 1 and 5 after wards makes sure that it is more than 5 always.

4 0
2 years ago
On a webpage, a _____ provides supplemental material such as social networking feeds and ads. Group of answer choices footer sid
finlep [7]

Answer:

sidebar

Explanation:

The part of the webpage that is being described in this question is known as a sidebar. These are the far left/right sides of the webpage and are usually used for networking feeds, ads, related information, major points of the main page, biographical info, as well as persuasive information. This section of the webpage serves two main purposes to provide the viewer with advertisements and to encourage the reader to read the more detailed main article.

8 0
2 years ago
Other questions:
  • Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting? Mr. Crowell has
    9·2 answers
  • Refer to the exhibit. pc1 issues an arp request because it needs to send a packet to pc3. in this scenario, what will happen nex
    9·1 answer
  • Write a program to determine all pairs of positive integers, (a, b), such that a &lt; b &lt; 1000 and [a2 + b2 + 1)/(ab) is an i
    13·1 answer
  • Samuel received an email that looked like it came from his bank. The email told him to click a link that opened an official look
    7·1 answer
  • 14. Emelia is very concerned about safety and has conducted a study to determine how many bike helmets were replaced at each loc
    13·2 answers
  • In Section 8.5.4, we described a situation in which we prevent deadlock by ensuring that all locks are acquired in a certain ord
    11·1 answer
  • A company decides to relocate its operations to another state in order to take advantage of some new business investment credits
    15·1 answer
  • For a class project, Jerome builds a simple circuit with a battery and three light bulbs. On his way to school, Jerome drops his
    9·1 answer
  • CHALLENGE ACTIVITY 3.7.2: Type casting: Reading and adding values.
    10·1 answer
  • 5.19 LAB: Exact change - functions
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!