Android examples for java.lang:Math Formula
Formula to calculate pyramid Volume
import java.text.DecimalFormat; public class Main{ private static double result; public static double pyramidVolume(double baseArea, double height) throws InvalidInputException { if (baseArea >= 0 && height >= 0) { result = (baseArea * height) / 3; return result; } else {/*from w w w. j ava 2 s. c om*/ throw new InvalidInputException(); } } }