Write a java program to input three angles of a triangle and print if a triangle with those angles is valid or not. The angles of a valid triangle are all positive and add up exactly 180. For valid Triangles also print if the triangle is acute (all the three angles are < 90"°"), obtuse (one of the three angles is > 90"°") or right angled (all angles are = 90"°").
Using if else
plzzz answer it clearly
Answers
import java.util.*;
class Triangle
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the three angles");
int a1=sc.nextInt();
int a2=sc.nextInt();
int a3=sc.nextInt();
if((a1+a2+a3)==180)
{
System.out.println("it is a valid triangle");
if(a1<90 && a2<90 && a3<90)
System.out.println("it is an acute angled triangle");
else if(a1>90 || a2>90 || a3>90)
System.out.println("it is an obtuse angled triangle");
else
System.out.println("it is a right angled triangle");
}
else
System.out.println("it is not valid");
}
}
Answer: import java.util.*;
class Triangle
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the three angles");
int a1=sc.nextInt();
int a2=sc.nextInt();
int a3=sc.nextInt();
if((a1+a2+a3)==180)
{
System.out.println("it is a valid triangle");
if(a1<90 && a2<90 && a3<90)
System.out.println("it is an acute angled triangle");
else if(a1>90 || a2>90 || a3>90)
System.out.println("it is an obtuse angled triangle");
else
System.out.println("it is a right angled triangle");
}
else
System.out.println("it is not valid");
}
}
Read more on Brainly.in - https://brainly.in/question/9424781#readmore