JAVA——第二章2.16
作者:互联网
问题:六边形面积
编写程序 提示用户输入六边形的边长,然后显示其面积。
import java.util.Scanner;
public class Hexagon {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the length of the side:");
double s = input.nextDouble();
double area = ((3*Math.sqrt(3))/2)*s*s;
System.out.println("The area of the hexagon is " + area);
}
}
标签:JAVA,Scanner,area,System,input,2.16,第二章,public,out 来源: https://blog.csdn.net/PGLWGES/article/details/122774732