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
how do we provide security for web services
Is anyone has done the ASP.NET MVC4 workshop course(2 days) from Peers Technologies. Let me know. I need to talk before joining ASP.NET MVC4 training at peers, Hyderabad.
1) How can u create the table?
How to set fixed width in particular
what is integration testing in real time applications?
Given an array of size n. It contains numbers in the range 1 to n. Find the numbers which aren?t present.
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
we create a pf with 3 fields.2 is defined as keyfields.we lock it with alcobj command.how we find out whether the file is locked or not?is it dspfd??/
could you please tell me how to draw the calibration curve for HPLC {the software which we are using}?
Is the IT field raise again? What is the position of IT after 4 years?
In an customer exit (include Z) program, only the last record is getting fetched. The exit is getting called after pressing save button. What to write for fetching the first record ? Before saved to a SAP table how can i call all these records in an itab in the exit ?
how does database connection using ADO.NET?
hii I inntrested abt scjp certification but i dont knw abt scjp plz send details abt scjp exam and syllabus.
what is the meaning of without standing arrears?
What is BASIS