Calculates the area of a circle. - Java java.lang

Java examples for java.lang:Math Geometry Shape

Description

Calculates the area of a circle.

Demo Code

/*// w  w w .j  a va2 s  .com
 * Copyright (c) 2011-Present. Codeprimate, LLC and authors.  All Rights Reserved.
 * 
 * This software is licensed under the Codeprimate End User License Agreement (EULA).
 * This software is proprietary and confidential in addition to an intellectual asset
 * of the aforementioned authors.
 * 
 * By using the software, the end-user implicitly consents to and agrees to be in compliance
 * with all terms and conditions of the EULA.  Failure to comply with the EULA will result in
 * the maximum penalties permissible by law.
 * 
 * In short, this software may not be reverse engineered, reproduced, copied, modified
 * or distributed without prior authorization of the aforementioned authors, permissible
 * and expressed only in writing.  The authors grant the end-user non-exclusive, non-negotiable
 * and non-transferable use of the software "as is" without expressed or implied WARRANTIES,
 * EXTENSIONS or CONDITIONS of any kind.
 * 
 * For further information on the software license, the end user is encouraged to read
 * the EULA @ ...
 */
//package com.java2s;

public class Main {
    /**
     * Calculates the area of a circle.
     *
     * @param radius a double value indicating the radius of the circle.
     * @return the area of a circle given the radius.
     * @see #ellipseArea(double, double)
     */
    public static double circleArea(final double radius) {
        return ellipseArea(radius, radius);
    }

    /**
     * Calculates the area of an ellipse.
     *
     * @param radiusLength a double value indicating the radius length of the ellipse (x axis).
     * @param radiusHeight a double value indicating the radius height of the ellipse (y axis).
     * @return the area of an ellipse given the radius length and height.
     * @see java.lang.Math#PI
     */
    public static double ellipseArea(final double radiusLength,
            final double radiusHeight) {
        return (Math.PI * radiusLength * radiusHeight);
    }
}

Related Tutorials