Given two coordinates, Print the line equation

Objective: Given two coordinates (x1, y1) and (x2, y2). Write a java program to construct a line equation that passes through the given coordinates.

Line Equation:

Given two coordinates (x1, y1) and (x2, y2) the line equation is 
y - y1 = m(x - x1) where m is the slope of the line, where slope = (y2-y1)/(x2-x1)

Example:

Given coordinates: [3,7] and [5,11]
Line Equation: y = 2x + 1
Given coordinates: [2,2] and [4,12]
Line Equation: y = 5x -8

Complete Code:

Output:

Given coordinates: [2,2] and [4,12]
Line Equation: y = +5x -8

__________________________________________________
Top Companies Interview Questions..-

GoogleMicrosoftAmazonFacebookmore..

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: