Formula to calculate trapezoid Perimeter - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate trapezoid Perimeter

Demo Code


import java.text.DecimalFormat;

public class Main{
    private static double result;
    public static double trapezoidPerimeter(double base1, double base2,
            double base3, double base4) throws InvalidInputException {
        if (base1 >= 0 && base2 >= 0 && base3 >= 0 && base4 >= 0) {
            result = (base1 + base2 + base3 + base4);
            return result;
        } else {/* w w  w .  jav  a2  s .c om*/
            throw new InvalidInputException();
        }
    }
}

Related Tutorials