+ 1

Help me Write a function that shows that a given triangle is isosceles

Triangle type, java or js

26th Nov 2016, 11:09 PM
Kelby Boateng
Kelby Boateng - avatar
3 odpowiedzi
+ 1
I will assume that your triangle is made of 3 Points, each composed of x and y coordinates. You may need to do a function to calculate distance between two points, first. double distance(Point a, Point b) { return Math.sqrt(Math.pow(a.x-b.x, 2) + Math.pow(a.y-b.y, 2)); } Then, assuming your Triangle object has 3 points called a, b and c: boolean isIsoceles() { return (distance(this.a, this.b) == distance(this.a, this.c) || distance(this.a, this.b) == distance(this.b, this.c) || distance(this.a, this.c) == distance(this.b, this.c)); }
26th Nov 2016, 11:49 PM
Pierre Varlez
Pierre Varlez - avatar
+ 1
Pierre gave you a lot of help You now have the functionality to do want you ask, that's the propose of this app LEARN, EXCHANGE KNOWLEDGE, this is not a Do my all my homework group
27th Nov 2016, 4:42 PM
Dago VF
Dago VF - avatar
0
please how can I get to work in java, since what you provided is just like a guide. I mean can we try actual values.... Thanks
27th Nov 2016, 7:32 AM
Kelby Boateng
Kelby Boateng - avatar