(几何:六边形面积)编写程序,提示用户输入六边形的边长,然后显示它的面积。计算六边形
面积的公式是:
这里的 s 就是边长。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dome2_16;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class Dome2_16 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner in = new Scanner(System.in);
System.out.print("Enter the side:");
double side = in.nextDouble();
double area = 3 * Math.pow(3, 0.5) / 2 * Math.pow(side, 2);
System.out.println("The area of the hexagon is " + area);
}
}