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]
2 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]2 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
radioactive decay of 40k in an igneous rock has resulted in a ratio of 25 percent 40k atoms to 75 percent of 40ar and 40ca atoms
kenny6666 [7]
They Are 40k btw your welcome
3 0
3 years ago
It’s either B or D <br><br> Help please
-Dominant- [34]

D. Weight

People who weigh more will generally have more water present in their bodies. This water has a dilution effect on alcohol that is consumed, resulting in lower blood alcohol content. If two people consume the same amount of alcohol, the person who weighs more will generally have a lower blood alcohol content if other factors are equal.

5 0
3 years ago
Read 2 more answers
Noooooooooooooooooooooooooooooooo
Ilia_Sergeevich [38]

Answer:

what happened

Explanation:

3 0
3 years ago
Read 2 more answers
Which statement best describes a person who is following through on a previously made decision?
Nadusha1986 [10]

Answer:

The two

all the world now ok?

7 0
2 years ago
Read 2 more answers
A pill claims that it promotes better memory. A label on the bottle reads:
Ket [755]
The answer is, infact, D. You were right.
3 0
3 years ago
Other questions:
  • The _____ function of social work focuses on eliminating factors that hinder an individual’s ability to function effectively and
    11·1 answer
  • You are an immunologist and have a patient who has just received a kidney transplant. How do you explain to him the he must be g
    11·1 answer
  • How are the chemical senses different from the non-chemical senses?
    13·1 answer
  • Nees help pips :€ math and i will give you extra points
    15·2 answers
  • How are the accounts of Mali and Mogadishu similar and different
    10·1 answer
  • After the latest Social Studies lecture, Alma’s notes span 5 whole pages, front and back. Which note taking mistake does it soun
    8·1 answer
  • Describe the Ten Gurus and their relationship to Sikhism.
    6·1 answer
  • The writer wants sentence 20 (reproduced below) to provide commentary that reflects the complexity of the discussion in the para
    5·2 answers
  • Point of view in frida Kahlo
    11·2 answers
  • Que pasó diez años antes que los españoles viniese a esta tierra?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!