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


Please Help Members By Posting Answers For Below Questions

What sysoption determines where the macro facility searches a specific catalog for complied macro?

1658


details description on this mantis? who is founder of this mantis?

1687


When will you use shell script/Perl ahead of C/C++?

660


How to use string functions in QTP?give some examples

7127


What is test execution and when will we start execution please send me one example for this question

1433






Difference between HTML and DHTML?

1672


what is session state?

1532


what are other resources are needed for this mantis?

1526


9.Difference between even and odd signals?explain with the diagram?

2970


how do find the user exit for selected feild whatis the process and can u plz explain it

1731


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...

1587


how to work search engine? plz detail answer me.

1493


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.

1440


I want to pass .pdf files as OlE Object to crystal report through VB6. Please any one guid me...

2602


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

1625