Write a java program to accept three positive integers as input and check whether the given numbers form an acute- angle triangle or not. If the input numbers forms an acute - angle triangle then print "Acute triangle" else" Not an Acute triangle" in case of zero or negative input print "invalid".
Note: Rule to form an acute-angle triangle is, all three angles should be less than 90 degree and sum of all three angles should be equal to 180 degree.
Answers
Answer:
Explanation:
import java.util.Scanner;
public class ValidTriangle {
public static void main(String[] args) {
Scanner sn = new Scanner(System.in);
System.out.println("Enter first angle of triangle:");
double a = sn.nextDouble();
System.out.println("Enter second anglr of triangle:");
double b = sn.nextDouble();
System.out.println("Enter third angle of triangle:");
double c = sn.nextDouble();
if(a+b+c==180)
{
if(a<90&&b<90&&c<90)
{
System.out.println("It's an acute angled triangle");
}
else
{
System.out.println("Not acute angled triangle!");
}
}
else
{
System.out.println("Invalid value");
}
}}