Overview Create a Java class called Triangle that when used

Overview Create a Java class called Triangle that when used with the supplied driver TestTriangle. java displays some properties of your triangle. Do not change any of the code in TestTriangle.java. Specifications Create a Java class file called Triangle. java that creates a Triangle object that stores the following information: ·Length of side 1, ·Length of side 2, Length of side 3, and A scanner object for input. When the buildTriangle) method is invoked, ask the user to input the lengths of the three sides of a triangle. After receiving the three values, your program should provide answers for each of the following questions: Is it really a triangle? If one side is longer than the sum of the other two sides, then it is not. Is it an equilateral triangle? That is, are all three sides the same? that the triangle is equilateral, then it should NOT state that it is isosceles.) . Is it a right triangle? That is, does it satisfy the Pythagorean Theorem? . Is it an isosceles triangle? That is, are two sides the same? (If your program has already determined . what is the area of the triangle? Use vAs-als-b)(c), where s-perimeter What is the perimeter of the triangle? Notes/Hints You should break up your program into multiple methods. I have provided you with templates for The default constructor Triangle) The public method buildTriangle0 . The private method getSide(int index) It remains for you to write the code for the following public methods classifyTriangle) perimeter()

Solution

first enter the 3 sides of the triangle. then u can see the results.

import java.util.*;
class Triangle
{
   public static void main(String args[])
   {
       Scanner s=new Scanner(System.in);
       Double a=s.nextDouble();
       Double b=s.nextDouble();
       Double c=s.nextDouble();
       Triangle vt   = new Triangle();
       if(a>b && a>c)
       {
         if((a*a)==(b*b)+(c*c))
           System.out.println(\"It is a right-angled triangle\");
         else
           System.out.println(\"It is not a right-angled triangle\");
        }
        if(b>c && b>a)
        {
            if((b*b)==(c*c)+(a*a))
               System.out.println(\"It is a right-angled triangle\");
            else
               System.out.println(\"It is not a right-angled triangle\");
        }
        if(c>a && c>b)
        {
            if((c*c)==(a*a)+(b*b))
               System.out.println(\"It is a right-angled triangle\");
            else
               System.out.println(\"It is not a right-angled triangle\");
        }
        if(vt.isTriangleValid(a, b, c))
        {
               System.out.println(\"Sides entered can form a triangle!\");
        }
        else
        {
                System.out.println(\"Sides entered cannot form a triangle!\");
        }
        if(a==b && a==c)
        {
           System.out.println(\"this is a equilletral triangle\");
       }
       if ((a==b && b!=c && a!=c) || (b==c && b!=a && c!=a) || (c==a & c!=b && a!=b))
           System.out.println(\"The triangle with sides \"+a+\",\"+b+\",\"+c+\" is an isosceles one\");
       Double d;
       d = (a + b + c )/ 2 ;
        Double area = Math.sqrt(d * (d - a) * (d - b) * (d - c));
        System.out.println(\"Area of Triangle is:\"+area+\" sq units\");
        Double perimeter=a+b+c;
        System.out.println(\"Perimeter of the triangle is:\"+perimeter);
   }

   private boolean isTriangleValid(double a, double b, double c)
   {
            if((a+b)>c && (a+c)>b && (b+c)>a)
            {
                return true;
           }
           else
           {
                return false;
            }
   }
}

 Overview Create a Java class called Triangle that when used with the supplied driver TestTriangle. java displays some properties of your triangle. Do not chang
 Overview Create a Java class called Triangle that when used with the supplied driver TestTriangle. java displays some properties of your triangle. Do not chang

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site