Formula to calculate triangle Perimeter - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate triangle Perimeter

Demo Code


import java.text.DecimalFormat;

public class Main{
    private static double result;
    public static double trianglePerimeter(double base, double side1,
            double side2) throws InvalidInputException {
        if (base >= 0 && side1 >= 0 && side2 >= 0) {
            result = (base + side1 + side2);
            return result;
        } else {//from  ww  w .j av a2s  .  c  o  m
            throw new InvalidInputException();
        }
    }
}

Related Tutorials