用数学公式求六面形的面积
- 题目要求
- 代码
import java.util.Scanner;
public class Theareaofhexagon {
public static void main(String[] args) {
// TODO code application logic here
Scanner input=new Scanner(System.in);
System.out.println("Enter the side:");
double side=input.nextDouble();
double hexagonarea=(6*(Math.pow(side,2)))/(4*(Math.tan(Math.PI/6)));//运用Math类,这是一个系统类不需要声明
System.out.println("The area of the hexagon is"+hexagonarea);
}
}
- 运行结果