Android examples for java.lang:Math Formula
Formula to calculate rectangle Perimeter
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(); } } }