3847 - 2.22几何方面:六边形面积

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

(几何方面:六边形面积)编写程序,提示用户输入六边形的边长,然后显示它的面积。计算六边形面积的公式是:

                    

题目输入

在屏幕上显示这段文字 Enter the side: 输入数据

题目输出

在屏幕上显示这段文字The area of the hexagon is  输出结果

输入/输出样例

输入格式

Enter the side: 5.5  

输出格式

The area of the hexagon is 78.5895     

Java解答

import java.util.Scanner;
public class Main {
	
public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
double s=5.5;
double a1=Math.round((s*s*3*1.732*10000)/2);
double a=a1/10000;
System.out.printf("The area of the hexagon is "+a);
	}

}