write a program to check whether a triangle is valid or not, when the threeangles of the triangle are entered through the keyboard. A triangle is valid if the sumof all the three angles is equal to 180 degrees
/*write a program to check whether a triangle is valid or not, when the threeangles of the triangle are entered through the keyboard. A triangle is valid if the sumof all the three angles is equal to 180 degrees.*/
package com.company;
import javax.security.sasl.SaslClient;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
int a,b,c,sum;//angle of triangle
Scanner angle= new Scanner(System.in);
System.out.print("side a : ");
a=angle.nextInt();
System.out.print("side b : ");
b=angle.nextInt();
System.out.print("side c : ");
c=angle.nextInt();
//sum of angle of trinagle
sum=a+b+c;
if (sum==180)
{
System.out.println("Triangle is valid");
}
else
System.out.println("Triangle is not valid");
}
}
output:-
side a : 25
side b : 26
side c : 56
Triangle is not valid
Process finished with exit code 0
Comments
Post a Comment