コツコツ学習ブログ

プログラマのweb上のメモ的なもの

三角形と、円の面積をそれぞれ求めるメソッド

public class Main {

    public static double calcTriangleArea(double bottom, double height) {
        //底辺 * 高さ / 2
        double result = (bottom * height) / 2;
        return result;
    }

    public static double calcCircleArea(double radius) {
        //半径 * 半径 * 3.14
        double result = (radius * radius) * 3.14;
        return result;
    }

    public static void main(String[] args) {
        System.out.println(calcTriangleArea(10, 5.0));
        System.out.println(calcCircleArea(5.0));

    }
}