Question: 1- Write a Java code that asks the user to enter the integer (x, y) coordinates of two points that form a straight line,
1- Write a Java code that asks the user to enter the integer (x, y) coordinates of two points that form a straight line, reads these coordinates, and calculate the slope (a) and the slope-intercept (b) that form the equation of the straight line as follows: y = ax + b a = (y2 - Y)/(x2-X1) b = y2 - a*x2 Then ask the user to enter the integer (XA, YA) coordinate of a point A, read this data, and calculate the distance from this point A to the above straight line: Then you need to get the equation of the line that passes through A and is perpendicular to the original one as follows: The slope of the perpendicular line (ap) is the negative inverse of the slope of the original line: ap = -1/a The slope-intercept (be) of the perpendicular line is calculated by replacing the coordinates of point A into the equation: hectivate Wi Go to Settings 1- Write a Java code that asks the user to enter the integer (x, y) coordinates of two points that form a straight line, reads these coordinates, and calculate the slope (a) and the slope-intercept (b) that form the equation of the straight line as follows: y = ax + b a = (y2 - Y)/(x2-X1) b = y2 - a*x2 Then ask the user to enter the integer (XA, YA) coordinate of a point A, read this data, and calculate the distance from this point A to the above straight line: Then you need to get the equation of the line that passes through A and is perpendicular to the original one as follows: The slope of the perpendicular line (ap) is the negative inverse of the slope of the original line: ap = -1/a The slope-intercept (be) of the perpendicular line is calculated by replacing the coordinates of point A into the equation: hectivate Wi Go to Settings
Step by Step Solution
There are 3 Steps involved in it
Heres a Java code that accomplishes what youve described java import javautilScanner public class Li... View full answer
Get step-by-step solutions from verified subject matter experts
