Menu
Question Index
...


Write a program to get the type of the triangle formed by the given three points.
Note: When comparing the sides for equilateral trianlge, please round them to the nearest integer.

Input (Point, Point, Point) Output (String)
[0, 0], [5, 0], [0, 5] Isosceles Right Angled Triangle
[90, 0], [0, 0], [45, 77.94] Equilateral Triangle
[0, 2], [5, 0], [0, 5] Scalene Obtuse Triangle
[3, 1], [1.5, 1.2], [2.5, 4.3] Scalene Acute Triangle
[5, 10], [10, 10], [7.5, 12] Isosceles Obtuse Triangle

class ClassifyTriangle

{    public static void main(String s[])
    {
        Point firstPoint = new Point(0, 0);
        Point secondPoint = new Point(5, 0);
        Point thirdPoint = new Point(0, 5);
        System.out.println("Given three points forms : " + typeOfTriangle(firstPoint, secondPoint, thirdPoint));

    }


public static String typeOfTriangle(Point firstPoint, Point secondPoint, Point thirdPoint) {
//Write code here to get the type of triangle formed by the given points
}

//If required write any additional methods here
}
class Point {

double x;
double y;

Point(double x, double y) {
this.x = x;
this.y = y;
}
}

Doubts

Problems

Topic: Behavior Of Java Classes Using Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App