How do I calculate the perimeter of a triangle in java? [closed]

1

How do I calculate the perimeter of a triangle in java? I do not know how to calculate the perimeter of a triangle in java, anyone know? I already tried but could not, help me!

    
asked by anonymous 11.06.2015 / 21:05

1 answer

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 + "]";
    }

}
    
11.06.2015 / 23:27