Android examples for java.lang:Math Formula
Formula to calculate cone Volume
import java.text.DecimalFormat; public class Main{ private static final double PI = 3.141592653589793; private static double result; public static double coneVolume(double radius, double height) throws InvalidInputException { if (radius >= 0 && height >= 0) { result = ((PI * radius * radius * height) / 3); return result; } else {/*from w w w .j av a 2s .c o m*/ throw new InvalidInputException(); } } }