Formula to calculate triangle Area - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate triangle Area

Demo Code


import java.text.DecimalFormat;

public class Main{
    private static double result;
    public static double triangleArea(double base, double height)
            throws InvalidInputException {
        if (base >= 0 && height >= 0) {
            result = (base * height / 2);
            return result;
        } else {/* w  w w .j a  v  a  2s. com*/
            throw new InvalidInputException();
        }
    }
}

Related Tutorials