Computer Science, asked by preronasil80, 2 days ago

a Write program to imput three anglesola triangle and Scheck whether a triangle is possible Sample imput, 40,50,90
sample output: right=angled triangle​

Answers

Answered by Shivu516
0

Hope it helps ^_^

I have also added all the possible outputs

Please mark my answer as Brainliest in return :)

import java.util.Scanner;

public class TriangleTest{

       public static void main(String [] args){    

       System.out.println("Enter the 3 angles of the Triangle");

       Scanner sc = new Scanner(System.in);

       double a1 = sc.nextDouble();

       double a2 = sc.nextDouble();

       double a3 = sc.nextDouble();

       boolean result;

       if (a1 + a2 + a3 == 180)

       result = true;

       else

       result = false;

       if (result == true){

       if (a1 == 60 && a2 == 60 && a3 == 60)

       System.out.println("The given angles will make an Equilateral Triangle");

       if (a1 > 90 || a2 > 90 || a3 > 90)

       System.out.println("The given angles will make an Obtuse Angled Triangle");

       if (a1 < 90 && a2 < 90 && a3 < 90 && a1 != 60 && a2 != 60 && a3 != 60)

       System.out.println("The given angles will make an Acute Angled Triangle");

       if (a1 == 90 || a2 == 90 || a3 == 90)

       System.out.println("The given sides will make a Right Angled Triangle");

       }

       if (result == false){

       System.out.println("The given angles cannot make a Triangle");

       }    

   }

}

Output:

(i)

Enter the 3 angles of the Triangle

60

60

60

The given angles will make an Equilateral Triangle

(ii)

Enter the 3 angles of the Triangle

120

40

20

The given angles will make an Obtuse Angled Triangle

(iii)

Enter the 3 angles of the Triangle

75

70

35

The given angles will make an Acute Angled Triangle

(iv)

Enter the 3 angles of the Triangle

90

45

45

The given sides will make a Right Angled Triangle

(v)

Enter the 3 angles of the Triangle

45

45

100

The given angles cannot make a Triangle

I have not added an option for Isosceles Triangle as it would make the Program even more complex.

An Isosceles Triangle will come in either of the Acute Angled Triangles or Obtuse Angled Triangle

Similar questions