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

时间:2021-04-15 21:49:30

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

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);
    }

}