Write a program to input three angles of a triangle and check whether its construction is possible or not. (A triangle is possible if the sum of all the angles = 180). If possible then check and display whether it is an acute angled triangle, right-angled triangleor an obtuse angled triangle. Otherwise, display „A Triangleis not possible‟.Also write code to find the second largest angle.Sample
Input : Enter three angles : 30, 70, 80Sample Output : Right Angled triangle
Answers
Question:-
- WAP to input 3 angles of a triangle and check if construction is possible or not
- If yes, Check and display if a triangle is acute angled, right angled or obtuse angled triangle.
- Else Display " triangle not possible".
- Also find second largest angle
Code Language:-
- Not mentioned
Since the code language is not mentioned in the question, it is done in Java
Java Code:-
package Coder;
import java.util.*;
public class Triangle
{
public static void main (String ar [])
{
Scanner sc=new Scanner (System.in);
System.out.println("Enter 3 angles");
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
if((a+b+c)==180)
{
System.out.println("Triangle possible");
if(((a<90)&&(a>0)) ll (b<90)&& (b>0) ll(c<90)&&(c>0))
System.out.println("Acute angled Triangle");
else if((a==90)ll(b==90)ll(c==90))
System.out.println("Right angled triangle");
else if(((a>90)&&(a<180)) ll ((b>90)&&(b<180)) ll ((c>90)&&(c<180)))
System.out.println("Obtuse angled triangle");
}
else
System.out.println("Triangle not possible");
}
if(a>b)&&(b>c)
System.out.println(b+" is second largest angle");
else if(b>c)&&(c>a)
System.out.prinrln(c+" is second largest angle");
else
System.out.println(a+" is second largest angle");
}
}
Variable Description:-
- a,b and c:- to accept 3 angles(each angle in onle variable) from the user