Question: Write a Java code that asks the user to enter integers (xA, yA) as the coordinate of a point A and the slope () and

Write a Java code that asks the user to enter integers (xA, yA) as the coordinate of a point A and the slope () and the slope-intercept () of a straight line, reads these data, and calculate the distance from this point A to the given straight line:

Line equation: y = x +

After reading the coordinates of the point and the line equation, you need to get the equation of the line that passes through A and is perpendicular to the original line as follows:

The slope of the perpendicular line (aP) is the negative inverse of the slope of the original line:

P = -1/

The slope-intercept (bP) of the perpendicular line calculated by replacing the coordinates of point A into the equation:

=

Once you get the equation of the perpendicular line, you need to calculate the coordinates (xI, yI) of the intersection point between the original line and the perpendicular one as follows. = =+

Lastly, get the distance as follows: =()2+()2

When printing the slope and the slope-intercept values, Do not enter them manually

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!