Formula to calculate cylinder Volume - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate cylinder Volume

Demo Code


import java.text.DecimalFormat;

public class Main{
    private static final double PI = 3.141592653589793;
    private static double result;
    public static double cylinderVolume(double radius, double height)
            throws InvalidInputException {
        if (radius >= 0 && height >= 0) {
            result = (radius * radius * PI * height);
            return result;
        } else {//from w ww .  j a  v a2s .c  o  m
            throw new InvalidInputException();
        }
    }
}

Related Tutorials