The program will take two integers from the user, say n1 and n2. It will then call the method sum(n1, n2) to calculate the sum of all numbers between n1 and n2, inclusive. The answer returned by the sum( ) method will then be displayed on the screen. For example, if the user enters 5 and 9, the program will print the value of 5+6+7+8+9. On the other hand, if the user enters 5 and -2, the program will print the value of 5+4+3+2+1+0+(-1)+(-2). Note: Do not assume the user will always enter the smaller number first.

Answers

Answer 1

The Java program will take two integers from the user and we are not assuming the user will always enter the smaller number first.

Step-by-step coding of the given problem:

import java.util.*;

class main{

public static void main(String args[])

{int n1,n2;

Scanner in=new Scanner(System.in);

System.out.print("Enter the starting number: ");

n1=in.nextInt();

System.out.print("Enter the ending number: ");

n2=in.nextInt();

System.out.println("The sum of the numbers from "+n1+" to "+n2+" is "+sum(n1,n2));

}

public static int sum(int n1, int n2)

{int i,sum=0,start,stop;

start=n2;

stop=n1;

if(n1<n2)

  {start=n1;

   stop=n2;

   }

for(i=start;i<=stop;i++)

    sum+=i;

return sum;

}

}

To learn more about Java Programming, visit: https://brainly.com/question/18554491

#SPJ9


Related Questions

technician a says that fuel pump modules are spring-loaded so that they can be compressed to fit into the opening. technician b says that they are spring-loaded to allow for expansion and contraction of plastic fuel tanks. who is right?

Answers

According to Technician A, fuel pump modules are spring-loaded so they can be compressed to fit the aperture.

Electric fuel pumps are often mounted in the fuel tank to utilize the fuel in the tank to cool the pump and ensure a steady supply of fuel. Each injector has a spring-loaded valve that is kept closed by the force of the spring. The valve doesn't open until fuel is squirted into it. The fuel pump driver module controls the voltage supplied to the fuel pump in a vehicle. By adjusting voltage, the module ensures ideal fuel pressure and flow to the engine throughout its entire operating range.

Learn more about voltage here-

https://brainly.com/question/29445057

#SPJ4

In an industrial process, the diameter of a ball bearing is an important measurement. The buyer sets specifications for the diameter to be 3.0 ± 0.01 cm. The implication is that no part falling outside these specifications will be accepted. It is known that in the process the diameter of a ball bearing has a normal distribution with mean μ = 3.0 and standard deviation σ = 0.005. On average, how many manufactured ball bearings will be scrapped?

Answers

On average, the percentage of manufactured ball bearings that will be scrapped is 4.56%.

What is the manufactured ball bearings about?

An example of a rolling element bearing is a ball bearing, which has three major purposes in addition to facilitating motion: carrying weights, lowering friction, and positioning moving machine elements.

Note that:

x1 = 3-0.01 = 2.99

x2 = 3+0.01 = 3.01

So, It can be scrapped by:

1−P(2.99 < Z <3.01)= 1−P (2.99 −3/ 0.005 < Z < 2.99+30.00/5)

=1−P(2.99 − 3/0.005 <  Z <2.99 + 3/0.005)= 1 − P ( −2 < Z <2)

=1−(P (Z < 2.0) − (P (Z> − 2.0)) = ( P (Z > 2.0) + P( Z < −2.0)=

2 x 0.0228 = 0.0456

Therefore, the Answer will be 4.56% of the manufactured ball bearings need to be scrapped.

Learn more about ball bearings from

https://brainly.com/question/24316492
#SPJ1


What growth opportunities are available for Robert in other markets outside of the US?

Answers

The growth opportunities that are available for Robert in other markets outside of the US are  Lower costs, cheaper production, premises as well as lower wages.

What is growth in international marketing?

Your business may benefit from growth and higher margins if you export your goods or services to another nation.

There are four cornerstones of international company to take into account: management commitment, product knowledge, operational capacity, and financial capability, whether you export presently or are debating whether you should.

Therefore, The basis is commitment. The general consensus is that you either go all in or you don't. Opportunities for market expansion include, for example: increasing access to resources like new goods and services, money, people, etc. greater productivity in the workplace. Improved customer service and a change in the consumer experience. the development of new markets for the goods or services of the organization.

Learn more about international marketing from

https://brainly.com/question/20860719
#SPJ1

See full question below

Expanding Into International Markets by Robert Burrus. What growth opportunities are available for Robert in other markets outside of the US?

refrigerant 134a is the working fluid in a solar power plant operating on an ideal rankine cycle. saturated vapor at 60 oc enters the turbine, and the condenser operates at a pressure of 6 bar. the rate of energy input to the collectors from solar radiation is 0.4 kw per m2 of collector surface area. determine the solar collector surface area, in m2, per kw of power developed by the plant.

Answers

The solar collector surface area, in m2, per kW of power developed by the plant is [tex]25.3 m^2/kW[/tex].

1. T1=[tex]60 ^{0}[/tex]C

H1=275.99 kJ/Kg (Enthalpy for saturated vapor [tex]60^{0}[/tex]C)

Hfg=137.42 kJ/Kg

2. P2= 6 bar

T2=21.58 C ( temperature of sat. liquid  6 bar)

H2=259.19  (enthalpy of sat. liquid  6 bar)

From the above conditions, the power generated can be found.

Wt.=H1-H2=275.99-259.19=16.8 KW )

3.After condensing:

T3=21.58 C

P3= 6 bar

4. After pump:

T4=21.58 C

the power required by the solar collector to bring the temperature of the fluid up to 60 C  and vaporize the fluid :

W=CpT + [tex]H_{fg}[/tex]

Cp= 0.857 KJ/kg

[tex]H_{fg}[/tex]=137.42

W=0.857x(60-21.58) + 137.42=170.35 KW

Area required:

A=[tex]170.35 kw/0.4 KW/m^2[/tex]

A=[tex]425.86 m^2[/tex]

Area/Power generated= A / Wt=[tex]425.86 m^2/16.8 KW[/tex]

Area/Power generated=[tex]25.3 m^2/KW[/tex]

What is solar radiation?

Solar radiation often referred to as solar energy or simply sunlight, is the general term for electromagnetic radiation emitted by the sun. Solar radiation can be captured and converted into useful forms of energy such as heat and electricity using various technologies.

Solar radiation produces heat, light and energy that all living organisms need. Infrared radiation provides heat to all habitats both on land and in water Without solar radiation, the earth would be about 32°C colder 25. Solar radiation provides the heat and light necessary for life on earth.

TYPES OF SOLAR RADIATION

Direct solar radiation. Diffuse solar radiation. Reflected solar radiation.

To learn more about solar radiation, refer;

https://brainly.com/question/23338147

#SPJ4

What type of drum system is mostly to be found on the rear of a modern front wheel drive vehicle ?

Answers

Drum Brakes are mostly to be found on the rear of a modern front wheel drive vehicle.

What Is Drum Brake?

Drum brakes have been around since 1900 ,patented until 1902 by Louis Renault.

A drum brake is a brake that , causes friction caused by a set of shoes or pads that press outward against a rotating cylinder-shaped part called a brake drum.It  rotates at the same speed as the wheel. The drum surrounds a set of brake shoes that are coated in materials that generate friction.

Types of drum brakes

Leading/Trailing Shoe type. Twin-leading shoeDuo Servo.

To know more about drum brakes from the given link

https://brainly.com/question/14210776

#SPJ13

Schains 21 LINKS
Achains 21 LinkS
N 40° 30' E
4 chains 25 LINKS
5 chains
N 40° 30' E
FARM
3 chains
N 49° 30' W
1
ROAD
OLO
1. Determine the area of the enclosed property in square feet and acres.
2. How many linear feet of fencing would the farmer need to fence in the entire property?
3. If the land is valued at $4500.00 per hectare, what price did the farmer pay for the parcel?
4. Determine the three unidentified internal angles of the polygon.
5. Determine the bearings of the unidentified sides of the parcel.

Answers

1. The area of the enclosed property is 10,000 square feet.

2. The farmer would need 1,000 linear feet of fencing to fence in the entire property.

3. The farmer paid $20,000 for the parcel.

4. The three unidentified internal angles of the polygon are 90°, 45°, and 45°.

5. The bearings of the unidentified sides of the parcel are North, South, and East.

What is angles of the polygon?

An angle of a polygon is generated by two sides of the polygon that share a terminal in geometry. If a point within the angle is in the interior of a simple (non-self-intersecting) polygon, regardless of whether it is convex or non-convex, this angle is called an interior angle (or internal angle). Each vertex in a polygon has precisely one internal angle. A simple polygon is said to be convex if every internal angle is less than radians (180°).

To learn more about angles of the polygon
https://brainly.com/question/24966296

#SPJ13

how does energy industry meet their compliance goals?

Answers

One of the biggest and most strictly regulated industries in the world is the energy and utilities (E&U) sector. For businesses that don't modernize their business practices, it can be challenging to comply with all the new and evolving regulations. E&U businesses can lower their risk of non-compliance by adopting a comprehensive strategy that incorporates automation and verification tools.

The Energy industry:

Let's begin by taking a look at some of the definitions and current trends in the energy sector. It will give us a helpful framework for some of the other crucial components of this quickly evolving sector.

What is it? 

The energy sector is enormous and encompasses a wide range of disciplines, occupations, and specializations. It generally refers to the production of electricity using fossil fuels like oil and gas, nuclear energy, and renewable sources like wind and solar.

This idea typically refers to three distinct areas: the production of the power itself, its transmission and distribution, and the sales and metering side. There are numerous energy-related businesses, markets, and jobs in each of these regions.

To know more about Energy, visit: https://brainly.com/question/19042109

#SPJ9

when a load resistor is connected across a voltage divider output, the output voltage increases. group of answer choices true false

Answers

When a load resistor is connected across a voltage divider output, the output voltage increases is false.

What is load resistor?

Load resistors are utilized to guarantee a minimal current flow, impedance matching, maximum power transfer, and improved output stability. At a circuit's output, load resistors are utilized to change the amount of power going to the load.

A resistor serving as a load is known as a load resistor. Depending on how much electricity it needs to dissipate (otherwise it wouldn't be much of a load), it might be extremely small or might need to be physically large.

*When reading about circuits, different resistors may be categorized according to what they do, so you might see "feedback," "damping," "source," "bias," etc. resistors.

Any device that draws power, whether it be a resistor, capacitor, inductor, or a combination of these three, is referred to as a load. According to Ohm's Law, a load resistor should be a pure resistive load that dissipates power.

                                    [tex]P = I^2 \times R[/tex]

and

                                   [tex]P = \frac{V^2}{R}[/tex]

where P stands for power lost, I for current, V for voltage, and R for resistance, expressed in ohms.Replace R with impedance Z, which is a combination of resistance and reactance, for inductive and capacitive loads.

Learn more about Load Resistor click here:

https://brainly.com/question/28105903

#SPJ4

Other Questions
Use "The Advantages of Having One Leg" by G.K. Chesterton. Read the text carefully. Then, in a well-developed essay, analyze the rhetorical strategies Chesteron uses to support his purpose.Can someone please help with this? Adjective? The dress is nearly new in a synergistic drug interaction group of answer choices one drug blocks the action of another drug. two drugs multiply each other's effects. two or more drugs combine to produce extremely uncomfortable reactions. an individual develops a tolerance to one drug that increases his or her tolerance to another drug. If a pharmacist fortified 10g 0f a 0.1% tacrolimus ointment by adding 12g of an ointment containing 0.05% of the same drug. What would be thea. total amount of the ointment after after fortification? what are the physiological consequences of sensory and motor pathways moving through the brainstem? select all that apply. 20 PTS!!An experiment that tests only one factor at a time by using a comparison of a control group and an experimental group is... A) a dependent variable B) an independent variable C) a controlled experiment D) a theory if 243 mg of mg(oh) 2 was neutralized with 0.0500 m hcl, what volume of hcl would you need for the neutralization? PLEASE HELP!!!Dianelys accepted a new job at a company with a contract guaranteeing annual raises. In the first year, Dianelys' salary will be $40000, and she will get a raise of $2500 every year. Make a table of values and then write an equation for S,S, in terms of n,n, representing Dianelys' salary after working nn years for the company.Number of Years at the Company Dianelys' Salary (Dollars)00 40000\hspace{3px}\color{green}{\checkmark}4000011 42500\hspace{3px}\color{green}{\checkmark}425004250022 45000\hspace{3px}\color{green}{\checkmark}450004500033 47500\hspace{3px}\color{green}{\checkmark}47500 your friend has decided to conduct market research to assist in making informed decisions for her/his small business. what should you recommend as the first step in the market research process? Why are there many different types of soils? maslow's hierarchy of needs includes physiological needs as a basic need. what does this mean for educators? A driver spotted a police car and he braked from a speed of 100km/h to a speed of 80km/h during a displacement of 88m, at a constant acceleration (a) What is that acceleration. (b) How much time is required for the given decrease in speed paula's projection screens inc. is trying to sell its product to a chain of movie theaters. this requires the sales rep, an engineer, and a quality control manager to attend meetings with the movie theater staff to provide answers to their questions. this is an example of . if a drawer and a payee or holder have accounts at different banks, the payer bank and depository bank are not the same bank. in this case, the check is called a(n) . why did kohler and lipton start by repeating a previous experiment? they wanted to make sure they could reproduce the results in their own laboratory. the more times the same result is obtained, the more confidence a researcher has in the results. they wanted to confirm that chicken cells behave similarly to mouse cells. they wanted a baseline for comparison to further studies involving purified platelet proteins. all of the answer options are correct. kyle knows that his spring break travel packages are the best deal on campus. he also knows his competitor is sloppy, often waiting until the last minute to provide the needed tickets and documents to students buying his island packages. kyle wants to develop an advertising message that emphasizes the key benefits he provides. he will develop a(n) blank appeal. given that the probability of a family owning a dog is 0.91, and the probability of a family owning a cat and a dog is 0.15, what is the probability of a family owning a cat given that the family owns a dog? a nurse is caring for a client who has sustained severe trauma and has developed disseminated intravascular coagulation (dic). the nurse will explain this complication to the family based on which physiologic principle? * i need to make a 2.00 m solution of sodium hydroxide. i have a 11.9 m solution of naoh on the shelf. how many ml of the 11.9 m solution of naoh do i need to make 2 liters of the 2.00 m naoh solution? Explain at least two ways that the Taft and the Wilson ad-ministrations continued to enact progressive reforms.Answer in at least two sentences.You may choose to answer with:One way that the Taft and the Wilson administrationscontinued to enact progressive reforms is ...