1
How do I calculate the perimeter of a triangle in java? I don’t know how to calculate the perimeter of a triangle in java, anyone knows? I tried but I could not, help me!
1
How do I calculate the perimeter of a triangle in java? I don’t know how to calculate the perimeter of a triangle in java, anyone knows? I tried but I could not, help me!
2
public class Triangulo {
private final double lado1;
private final double lado2;
private final double lado3;
public Triangulo(double lado1, double lado2, double lado3) {
this.lado1 = lado1;
this.lado2 = lado2;
this.lado3 = lado3;
}
public double getPerimetro() {
return lado1 + lado2 + lado3;
}
@Override
public String toString() {
return "Triangulo [lado1=" + lado1 + ", lado2=" + lado2 + ", lado3=" + lado3 + "]";
}
}
Browser other questions tagged java
You are not signed in. Login or sign up in order to post.
Post the code you have so far, tell if it is a method to calculate the perimeter just passing the values or is something more complex
– Maicon Carraro
Any type of triangle? put the source code even wrong, and detail the problem.
– rray
To calculate the perimeter of a triangle just add up the sides of it. How to do this in Java depends a lot on how your Triangulo class is doing. Post her here that gets easier to help.
– Math