Formula to calculate rectangle Perimeter - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate rectangle Perimeter

Demo Code


import java.text.DecimalFormat;

public class Main{
    private static double result;
    public static double rectanglePerimeter(double width, double height)
            throws InvalidInputException {
        if (width >= 0 && height >= 0) {
            result = (2 * width + 2 * height);
            return result;
        } else {/*from w  ww  . j av a  2 s. c o m*/
            throw new InvalidInputException();
        }
    }
}

Related Tutorials