2.16 题
public class App {
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the length of the side:");
double length = scanner.nextDouble();
double area = 3 * Math.sqrt(3) * Math.pow(length, 2) / 2;
System.out.println("the area of the hexagon is " + area);
}
}
static double sqrt(double a) 返回 double值的正确舍入正平方根。
static double pow(double a, double b) 返回第一个参数的值,该值是第二个参数的幂。