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
photoshop1234 [79]
2 years ago
5

Write a short java method that takes an integer n and returns the sum of all the odd positive integers less than or equal to n.

Computers and Technology
1 answer:
umka2103 [35]2 years ago
3 0
Public int add2n( int n )
{
    int total;
    if( n % 2 == 0 )
        total = n--;

    while( n > 0 )
    {
        total += n;
        n -= 2;
   }
   return( total );
}

You might be interested in
Is Using programming libraries is one way of incorporating existing code into new programs true
postnew [5]

Yes, Using programming libraries is one way of incorporating existing code into new programs  is a true statement.

<h3>What function do libraries provide in programming?</h3>

Programming libraries are helpful resources that can speed up the work of a web developer. They offer prewritten, reuseable portions of code so that programmers can easily and quickly create apps. Consider building a program that enables users to enroll in and pay for courses.

Therefore, Using a code library often saves developers from having to create everything from scratch. It can take less time to develop projects and have more reliable software if the catalog of programming resources is kept up well.

Learn more about libraries from

brainly.com/question/17960151
#SPJ1

6 0
1 year ago
Each wireless network has its own name to identify it, known as service set identity. true false
Dominik [7]
True. The acronym for service set identity is SSID, which you've likely saw before. And like you say, it's simply the unique name given to a wireless network so that we are able to identify what network we are connecting to.
8 0
2 years ago
How could social media have a negative impact if not used properly when seeking employment
castortr0y [4]
Before hiring someone, employers often check the social media pages of people applying for a job. If their social media account has content not up to the company's standards, they may not get the job. 
8 0
3 years ago
Consider the code fragment below (with nested loops). int sum = 0;for (int i = 1; i &lt; 5; i++) for (int j = 1; j &lt;= i; j++)
sammy [17]

Answer:

Option d is the correct answer for the above question.

Explanation:

  • The first loop of the program has a second loop and then the statement. In this scenario, the second loop executes for the value of the first loop and the statement executes for the value of the second loop.
  • The first loop executes 4 times, Then the second loop or inner loop executes n times for the n iteration of the first loop, for example, 1 time for the first iteration of the first loop, 2 times for the second iteration of the first loop and so on.
  • Then the inner loop executes (1+2+3+4) iteration which gives the result 10 iterations.
  • The sum initial value is 0 and the "sum++", increase the value of the sum by 1.
  • So the value of the sum becomes 10 after completing 10 iterations of the inner for loop.
  • Hence the 10 will be the output. So the Option d is the correct answer while the other is not.
3 0
3 years ago
You want high availability for DHCP services, a primary server to handle most DHCP requests, and a secondary server to respond t
babymother [125]

Answer:

The blocking system.

Explanation:

In order to avoid servers to replicate with each other, I should configure the blocking system of the first DHCP.

For example, if the first DHCP fails to respond, the second will get in place, however, I have to configure the first system that immediately that the second DHCP starts working, the first blocks its information and use.

By this way, there won´t be any duplicated actions or reponses.

5 0
3 years ago
Other questions:
  • When did the silver market drop sharply, hurting Bolivia's income?
    7·2 answers
  • Christine wants to send a quick communication to all department managers. She should send a _____. report
    13·2 answers
  • Incident damage ____ is the rapid determination of the scope of the breach of the confidentiality, integrity, and availability o
    6·1 answer
  • When you are working in Performance Monitor, in the "Add Counters" dialog box, and need more information about a particular coun
    8·1 answer
  • What is the way to discover requirments for software projects ?
    14·1 answer
  • Tech A states that modern vehicles use asbestos as the brake material. Tech B states that asbestos is no longer used in brakes.
    8·1 answer
  • Phishing (pronounced fishing) is malware sent through e-mail that looks like a legitimate message from a trusted sender. The goa
    10·2 answers
  • What is the impact of VR on Educational Learning rather than games?​
    13·1 answer
  • 2. How does the internet give us the ability to communicate?
    15·1 answer
  • What type of e-mail typically lures users to sites or asks for sensitive information?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!