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
What is Access? When would you use Access instead of Excel?
SpyIntel [72]

Answer:

Access is a database management system from Microsoft.

Explanation:

Access allows users to view, edit and delete data, manage database tables, forms, queries, reports and macros.

Access should be use instead of Excel when you need to manage data and have it organize, easy to search and available to different users. If you need to be able to track information that is in different categories but is related, Access is a better option.

4 0
4 years ago
List the actual network numbers for each of these subnets. (If the list is longer than 16, simply list the first 3 and final 3 "
Andre45 [30]
69 is the answer because I know or it could be 430
3 0
3 years ago
. simulation programs can use a range of integer values to mimic variability in the simulation. a. true b. false
RSB [31]

True, simulation programs can use a range of integer values to mimic variability in the simulation.

What are simulation programs ?

The foundation of simulation software is the process of simulating a genuine phenomena using a set of mathematical equations. In essence, it's a program that enables the user to simulate a process while still observing it in action.
It is theoretically possible to simulate on a computer any phenomenon that can be reduced to numerical values and equations.
Identifying the most crucial elements that have an impact on the simulation's objectives is one of the tricks to creating useful simulations.

Therefore, simulation programs can use a range of integer values to mimic variability in the simulation.

You can learn more about simulation programs from the given link:

brainly.com/question/27159343

#SPJ4

5 0
2 years ago
Information is stored on a compact disk in a coded pattern of tiny pits arranged in a track that spirals outward toward the rim
Maksim231197 [3]

Answer:

(i) The rotation speed must stay the same.

(ii) The rotation speed must increase.

(iii) The rotation speed must decrease.

Explanation:

According to Equation

10.10, the angular speed must therefore vary as the laser–lens system moves

radially along the disc. In a typical CD player, the constant speed of the surface at

the point of the laser–lens system is 1.3 m/s.

5 0
3 years ago
Rick is a fan of logic-based games. However, he is bored of the classic ones, like Sudoku and Mastermind, since he has solved so
Misha Larkins [42]

Answer:

The function is as follows:

import random

import string

def solution(riddle):

   s = list(riddle)

   for i in range(len(riddle)):

       alpha = "".join(random.choice(string.ascii_letters) for x in range(1))

       alpha = alpha.lower()

       if s[i] == '?':

           if i > 0 and i < len(s)-1:

               if s[i+1] != alpha:

                   s[i] = alpha

               elif s[i-1] != alpha:

                   s[i] = alpha

               else:

                   i=i

           else:

               if i == 0:

                   if s[1] != alpha:

                       s[i] = alpha

                   else:

                       i = i

               else:

                   if s[i-1] != alpha:

                       s[i] = alpha

                   else:

                       i = i

   riddle = ""

   for ele in s:

       riddle+=ele

   

   return riddle

Explanation:

See attachment for explanation where comments are used to explain some lines

Download txt
3 0
3 years ago
Other questions:
  • If you have a list of words that you wish to make into a bulleted list, you must first highlight or ________ the words with your
    14·1 answer
  • In nutanix command-line interface (ncli) commands, each entity has a unique set of actions, but a common action across all entit
    15·1 answer
  • Every time you are asked to work with others, you are being asked to:
    6·2 answers
  • Packet ________ is a form of protection for your computer that looks at each packet that comes into your computer network. scree
    15·1 answer
  • How can a user view the options for Junk E-mail?
    11·2 answers
  • Anyone know the name of this font? and what site i can find it on so i can type it????
    8·1 answer
  • Pick an appliance or an electronic device that you use at home that is powered from the wall outlet. Specify which electronics d
    10·1 answer
  • The information provided in text aids can help us to understand a text’s content before we even read it.
    8·1 answer
  • 334. Universal Containers uses a custom field on the account object to capture the account credit status. The sales team wants t
    12·1 answer
  • PLEASE HELP WHATS THE ANSWER
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!