Computer Science, asked by arpityadav75647, 1 year ago

Write a program to input three side of a triangle and check it is right angle triangle or not in Java

Answers

Answered by RoseV1
10

{

Scanner in=new Scanner(System.in);

System.out.println ("enter the sides of a triangle");

int a=in.nextInt ();

Int b=in.nextInt ();

Int c=in.nextInt ();

if (a <b &&b <c)

{

D=a*a+b*b;

E=c*c;

if (D=E)

Sop ("it's a right angled triangle");

Else

Sop ("not angled right angled triangle");

}

Else if (a> b&&aa> c)

{

D=c*c+b*b;

E=aa*a;

if (D=E)

Sop ("it's a right angled triangle");

Else

Sop ("not angled right angled triangle");

}

Else if (b> c&&b> a)

{

D=a*a+c*c;

E=b*b;

if (D=E)

Sop ("it's a right angled triangle");

Else

Sop ("not angled right angled triangle");

}

Else

Sop ("not a right angled triangle")

}


Answered by BrainlyPromoter
4

import java.util.Scanner;

public class RightAngledTriangleConfirmer

{

   public static void calc()

   {

       double h=0,p=0,ba=0;

       Scanner prince=new Scanner(System.in);

       System.out.print("To check whether your sides form a right angled triangle, enter the measurements of your sides.");

       double a=prince.nextInt();

       double b=prince.nextInt();

       double c=prince.nextInt();

       if(a>=b && a>=c)

       {

           h=a;

           p=b;

           ba=c;

       }

       else if(b>=a && b>=c)

       {

           h=b;

           p=a;

           ba=c;

       }

       else

       {

           h=c;

           p=b;

           ba=a;

       }

       double sqh=Math.pow(h,2);

       double sqp=Math.pow(p,2);

       double sqb=Math.pow(ba,2);

       if(sqh==sqp+sqb)

       System.out.println("Yes, the triangle is a right-angled triangle.");

       else

       System.out.println("No, the triangle is not a right-angled triangle.");

   }

}

Similar questions