Formula to calculate rectangle Area - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate rectangle Area

Demo Code


import java.text.DecimalFormat;

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

Related Tutorials