Android examples for java.lang:Math Formula
Formula to calculate triangle Area
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(); } } }