Given three sides of a triangle. Write the Program to
determine whether the triangle is :
1) Invalid
2) Right Angled
3) Isoscales
4) Equilateral
5) Not Special
An Isoscales right angled triangle should be taken as a
Right Angled Triangle
Answer Posted / ganesh bhat
I believe, this is more efficient one. solves all the cases.. comments please. Written in java
public static Map validateTriange(int a,int b,int c)
{
Map props = new HashMap();
boolean isValidTriangle;
int bigSide = a;
if(bigSide<b){bigSide = b;}
if(bigSide<c){bigSide = c;}
boolean isSpecial = false;
if((a+b+c-bigSide)>bigSide)
{
props.put("VALID","YES");
}
else
{
props.put("VALID","NO");
return props;
}
if(a == b||b==c||c == a)
{
props.put("ISOSCELES","YES");
isSpecial = true;
}
if(a == b && b == c)
{
props.put("EQUALATERAL","YES");
isSpecial = true;
}
if(((a*a+b*b+c*c)-bigSide*bigSide) == bigSide*bigSide)
{
props.put("RIGHT_ANGLED","YES");
isSpecial = true;
}
return props;
}
Is This Answer Correct ? | 22 Yes | 22 No |
Post New Answer View All Answers
What sysoption determines where the macro facility searches a specific catalog for complied macro?
details description on this mantis? who is founder of this mantis?
When will you use shell script/Perl ahead of C/C++?
How to use string functions in QTP?give some examples
What is test execution and when will we start execution please send me one example for this question
Difference between HTML and DHTML?
what is session state?
what are other resources are needed for this mantis?
9.Difference between even and odd signals?explain with the diagram?
how do find the user exit for selected feild whatis the process and can u plz explain it
is it possible to desable particular parameter of the normal orcle report based on some condition ?????? if yes,wht is the function for desabling a parameter...
how to work search engine? plz detail answer me.
without selecting individually each field in Action Class from jsp,what is the best process to select as many as field at a time automatically from jsp page by using value object class.
I want to pass .pdf files as OlE Object to crystal report through VB6. Please any one guid me...
What is easiest way to get the PL/i compiler,I didn't have found the compiler in my library. Is there any extra cost if we want to access the PL/1 programs?Actually we r having Mainframe rented training Ids