Formula to calculate pyramid Volume - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate pyramid Volume

Demo Code


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();
        }
    }
}

Related Tutorials