Menu
Question Index
...


Write a program to get the angles of a triangle by using the given points. Round the resultant angles to the nearest integer value.

Input (Point, Point, Point) Output (Angles)
[0, 0], [5, 0], [0, 5] 45.0, 90.0, 45.0
[90, 0], [0, 0], [45, 77.94] 60.0, 60.0, 60.0
[0, 2], [5, 0], [0, 5] 45.0, 112.0, 23.0
[0, 0], [10, 0], [5, 7.666] 66.0, 57.0, 57.0
[25, 43], [50, 0], [50, 43] 90.0, 60.0, 30.0

class CalculateThreeAngles

{    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("Angles of the triangle are : " + getAngles(firstPoint, secondPoint, thirdPoint));

    }


public static Angles getAngles(Point firstPoint, Point secondPoint, Point thirdPoint) {
//Write code here to get the angles of a triangle.
}

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

double x;
double y;

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

class Angles {

double angleA;
double angleB;
double angleC;

public Angles(double angleA, double angleB, double angleC) {
this.angleA = angleA;
this.angleB = angleB;
this.angleC = angleC;
}

@Override
public String toString() {
return (angleA + ", " + angleB + ", " + angleC);
}
}

Doubts

Problems

Topic: Java Math Class - java.lang.Math

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App