Computer Science, asked by debtirthoghosh, 1 day ago

Write a program to read three sides of a triangle and check whether they are right angled or not.
pls I need the correct answer​

Answers

Answered by samarthkrv
1

Answer:

import java.util.Scanner;

import java.lang.Math;

public class Triangle

{

public static void main(String[] args) {

 Scanner sc = new Scanner(System.in);

 System.out.print("Enter the adjacent side:");

 double adj = sc.nextDouble();

 System.out.print("Enter the opposite side:");

 double opp = sc.nextDouble();

 System.out.print("Enter the hypoteneuse side:");

 double hyp = sc.nextDouble();

     if(adj > hyp || opp > hyp){

         System.out.println("The triangle can not be formed.");

     }

     else if(Math.sqrt((opp*opp) + (adj*adj)) == hyp){

         System.out.println("The triangle can be formed.");

     }

     else{

         System.out.println("The triangle can not be formed.");

     }

}

}

Explanation:

Similar questions