Java语言程序设计(基础篇)原书第十版 课后习题 第四章

// 个人对本章理解非常差……但是本章非常重要,同志们要好好看啊

import java.util.Scanner;
public class Code_Practice_4 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.print("Enter the length from the center to a vertex:");
        double length = input.nextDouble();

        double side = 2 * length * Math.sin(Math.PI / 5);
        double area = (5 * side * side) / (4 * Math.tan(Math.PI / 5));

        System.out.printf("The area of the pentagon is %.2f:",area);
    }

}

猜你喜欢

转载自blog.csdn.net/zjjoebloggs/article/details/49069447
今日推荐