Computer Science, asked by PrantikBarik, 4 months ago

a) Write a program in Java to accept three angles of a triangle. Check whether the triangle is a
Acute-angled triangle, Right-angled triangle or Obtuse-angled triangle.​

Answers

Answered by mdtaha2122007
0

Answer:

Write a program to input three angles of a triangle and check whether a triangle is impossible or not . If possible then check whether it is an acute angled triangle , right angled triangle or an obtuse angled triangle otherwise, display 'Triangle not possible'. Sample input : Enter the angles: 40, 50 , 90.

Answered by deepakkumar9254
4

Program :-

import java.util.Scanner;    \\ importing package

class d     \\ class declaration

{

   public static void main (String args[])    \\ main()method declaration

   {

       Scanner sc=  new Scanner(System.in);    \\ input object creation

       System.out.println("Enter three angles of a triangle");

       int a = sc.nextInt();    

       int b = sc.nextInt();    

       int c = sc.nextInt();    

       int s = a+b+c;

       if (s == 180 && a > 0 && b > 0 && c > 0)  

       {

          if (a < 90 && b < 90 && c < 90)  

          {

              System.out.println("Acute-angled Triangle");

          }

          else if (a == 90 || b == 90 || c == 90)  

          {

              System.out.println("Right-angled Triangle");

          }

          else  

          {

              System.out.println("Obtuse-angled Triangle");

          }

          }

          else  

          {

          System.out.println("Triangle cannot be formed");

       }

   }

}

   

Output :-

Enter three angles of a triangle

90

45

45

Right-angled Triangle

Glossary :-

\begin{array}{| c | c | c |}\cline{1-3} \bf Variable &amp; \bf Type &amp; \bf Description\\ \cline{1-3} a &amp;\sf int &amp; to\:\:store\:\:the\:\:first\:\:angle \\ \cline{1-3} b &amp;\sf int &amp; to\:\:store\:\:the\:\:second\:\:angle \\ \cline{1-3} c &amp;\sf int &amp; to\:\:store\:\:the\:\:third\:\:angle \\ \cline{1-3} s &amp;\sf int&amp; to\:\:store\:\:the\:\:sum\:\:of\:\:all\:\:angles \\\cline{1-3}\end{array}

Similar questions