write a JAVA program to accept three angles of a triangle and check whether the triangle is possible or not .If possible then display weather in acute angle triangle ,right angle triangle or obtuse angle triangle
(using Stream Classes)
Answers
Given three sides, check whether triangle is valid or not.
Examples:
Input : a = 7, b = 10, c = 5
Output : Valid
Input : a = 1 b = 10 c = 12
Output : Invalid
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
Approach: A triangle is valid if sum of its two sides is greater than the third side. If three sides are a, b and c, then three conditions should be met.
1.a + b > c
2.a + c > b
3.b + c > a
filter_none
edit
play_arrow
brightness_4
// C++ program to check if three
// sides form a triangle or not
#include<bits/stdc++.h>
using namespace std;
// function to check if three sider
// form a triangle or not
bool checkValidity(int a, int b, int c)
{
// check condition
if (a + b <= c || a + c <= b || b + c <= a)
return false;
else
return true;
}
// Driver function
int main()
{
int a = 7, b = 10, c = 5;
if (checkValidity(a, b, c))
cout << "Valid";
else
cout << "Invalid";
}
Hope it helpful for you
please follow me