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
rosijanka [135]
3 years ago
8

Two lights will be arranged on a two-dimensional plane. The vertical distance between the two lights is stored in the double var

iable a. The
horizontal distance between the two lights is stored in the double variable b.

The straight-line distance between the two lights is given by the formula

ſa² +b²

Write a code segment that prints the straight-line distance between the two lights according to the formula above.
Advanced Placement (AP)
1 answer:
lbvjy [14]3 years ago
6 0

Answer:

double a;

double b;

double distance = Math.sqrt( (Math.pow(a, 2) + Math.pow(b, 2));

System.out.println("The distance is: " + distance);

Explanation:

The code snippet is written in Java.

First, variable a is declared as a type of double and variable b is also declared as a type of double.

The given formula for the distance is:

√(a² + b²)

So we use the inbuilt function of Java to calculate the power and the square root.

Math.sqrt is to find the square root and it returns a value of type double.

Math.pow is use to calculate the value of a² and b².

a² = Math.pow(a, 2)

b² = Math.pow(b, 2)

Then Math.sqrt is applied to the sum of Math.pow(a, 2) and Math.pow(b, 2), the value is assigned to distance of type double.

The value of distance is now displayed to the user:

System.out.println("The distance is: " + distance);

You might be interested in
During what period does the peer group become a major influence, for good and bad?
Elena L [17]

Answer:

During adolescence

Explanation:

A peer group is a group of people who have similar interests, age, background, or social status. Peer groups influence a person during their entire life, but their impact is the most important during adolescence. Adolescents tend to spend less time with their parents, whose influence is the greatest during childhood, and spend more time with their peers. This is especially noticeable in the case of those who are not close or have many conflicts with their parents. Such individuals seek support elsewhere, usually turning to their peers. Most adolescents in this situation do not carefully choose what kind of group they join. If they are accepted, it does not matter if the group's influence is good or bad. Gangs are a common example of a peer group characterized by negative or even illegal activities.

4 0
3 years ago
AP Psychology chapter 2
olganol [36]
Hypothesis independent variable
5 0
2 years ago
Refer to the passage.
nlexa [21]

Answer:

b

Explanation:

7 0
3 years ago
Read 2 more answers
Chapter 22 in Two Roads by Joseph Bruchac is about how Cal has a brief encounter with an instructor
yan [13]
Is this supposed to be a question or??
5 0
3 years ago
What grade does 5th graders be in?
babunello [35]
Scientifically in the United States fifth graders would be in fifth grade
5 0
2 years ago
Read 2 more answers
Other questions:
  • how did the development of the british colonies along the southern atlantic coast and in the west indies compare with the develo
    12·2 answers
  • What else helps your stomach if you cant eat bread need answer asap its an emergency
    14·2 answers
  • Having which trait will enable you to deal with people in a way that does not offend them?
    6·1 answer
  • Which best describes the purpose of this document?
    16·2 answers
  • The equations of the tangent to the curve y=xsinx at the point (pi/2,pi/2) is
    7·1 answer
  • What part of the brain is responsible for speech
    10·1 answer
  • -Source: Edward Humes, historian, Over Here: How the G.I. Bill Transformed the American Dream, 2014
    7·1 answer
  • A 8-acre piece of land is subdivided into 4/7-acre lots. How many lots are there?
    7·1 answer
  • Which of the following is NOT a characteristic of a bureaucracy?
    7·1 answer
  • Population patterns shown on the map indicate that areas around river deltas and upland lake and river valleys have higher densi
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!