+ 1
Help me Write a function that shows that a given triangle is isosceles
Triangle type, java or js
3 ответов
+ 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));
}
+ 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
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