Menu
Question Index
...

Write a program to get the details of the line passing through the given points. Also implement the toString method for Line class, such that the details are printed as shown in the requirements

Input (Integer, Integer, Integer, Integer) Output (Line)
2, 3, 1, 5 y=-2.0x+7.0
12, 12, 14, 18 y=3.0x-24.0
0, -6, 3, 0 y=2.0x-6.0
-4, 0, 0, -20 y=-5.0x-20.0
3, 18, 2, 14 y=4.0x+6.0



class GetLineDetails
{
    public static void main(String s[])
    {
        System.out.println("Line equation is : " + getLineEquation(2, 3, 1, 5));

    }


    public static Line getLineEquation(int x1, int y1, int x2, int y2) {
    }

}
class Line {

double slope;
double intercept;

public Line(double slope, double intercept) {
this.slope = slope;
this.intercept = intercept;
}

}

Doubts

Problems

Topic: Java Multiple Methods In One Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App