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
.13 LAB: Library book sorting Two sorted lists have been created, one implemented using a linked list (LinkedListLibrary linkedL
Gre4nikov [31]

Answer:

linkedListOperations = linkedListLibrary.InsertSorted(currNode, linkedListOperations); // this is right

linkedListLibrary.InsertSorted(currNode, linkedListOperations);  // half right, it count how much operation but it doesn't store it anywhere in main.

vectorOperations = vectorLibrary.InsertSorted(tempBook, vectorOperations);  // this is right

vectorLibrary.InsertSorted(tempBook, vectorOperations); // half right, it count how much operation but it doesn't store it anywhere in main.

cout << "Number of linked list operations: " << linkedListOperations << endl;

cout << "Number of vector operations: " << vectorOperations << endl;

Explanation:

The first, you are calling InsertSorted with linkedListLibrary and than you can store the number of operation inside the "linkedListOperations" variable. Then you do the same with vectorLibrary.

7 0
2 years ago
In an ISDN connection, what amount of throughput did a single B channel provide?
Flura [38]

Answer:

64 Kbps

Explanation:

ISDN stands for Integrated Services Digital Network. It makes use of two types of channels:

B type : which is used for carrying data/voice

D type : which carries control and signalling information.

ISDN supports two different service levels:

  • Basic Rate Interface (BRI) - home and small users
  • Primary Rate Interface(PRI) - larger enterprise scenarios

Both BRI and PRI make use of set of B and D type channels for data transfer.

Each B channel or Bearer channel has a throughput of 64 Kbps whereas D channel has a throughput of 16 Kbps.

3 0
2 years ago
Enter an input statement using the input function at the shell prompt. When the prompt asks you for input, enter a number. Then,
Pavel [41]

Answer:

<u>Explanation:</u>

An input statement using the input function at the shell prompt is as follows:

If a prompt asks for a input, a number is to be added

num = input ('Number: ')

num = num + 1

print(num)

Explanation of results: This gives error at line num= num + 1 as cannot convert int object to str implicitly

8 0
1 year ago
Zander is beginning to take college courses to prepare for a career in computer science, which is the study of using logic to cr
scoundrel [369]

The answer is (A. career definition and career requirements  )


7 0
2 years ago
Provide one example of how information technology has created an ethical dilemma that would not have existed before the advent o
kolezko [41]

Answer:

One of the  top ethical dilemma is privacy issue.

Explanation:

With advent of I.T., personal data are kept in a digital platform which can be vulnerable to security breach. Hacker or other unauthorized parties can find their way to breach the computer system and steal the private information of the user.

Besides, the users' activities of computer machine can also be tracked. This is often happen in a corporate world where some employers tend to monitor their staffs' work performance through the computer. This can be an offence to the privacy of an individual.

4 0
2 years ago
Other questions:
  • A chemical found in the synaptic vesicles , which , when released . has an effect on the next cell is called a?
    10·1 answer
  • Which is true for a hosted blog software
    15·2 answers
  • Leo lives in a two-story home in an upscale neighborhood, drives a brand-new sports car, and makes more than $250,000 per year.
    13·2 answers
  • _____ is the process of adjusting colors in an image.
    13·2 answers
  • 5.William travels a lot on business purpose. He needs to regularly communicate with his business partner. He also needs to send
    15·1 answer
  • Because of the density of vehicle in urban areas, you should ____.
    8·2 answers
  • Assume that success is a variable of type boolean that has been declared. Assume that processor refers to an object that provide
    6·1 answer
  • There are two methods of enforcing the rule that only one device can transmit. In the centralized method, one station is in cont
    5·1 answer
  • Define a method printAll() for class PetData that prints output as follows with inputs "Fluffy", 5, and 4444. Hint: Make use of
    13·1 answer
  • On a webpage, a _____ provides supplemental material such as social networking feeds and ads. Group of answer choices footer sid
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!