Formula to calculate circle Perimeter - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate circle Perimeter

Demo Code


import java.text.DecimalFormat;

public class Main{
    private static final double PI = 3.141592653589793;
    private static double result;
    public static double circlePerimeter(double radius)
            throws InvalidInputException {
        if (radius >= 0) {
            result = 2 * radius * PI;/*from  w ww.  jav a  2s.  c om*/
            return result;
        } else {
            throw new InvalidInputException();
        }
    }
}

Related Tutorials