/*
* Copyright (c) 2015, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.java
* 作 者:王元阳
* 完成日期:2015 年 10 月 13 日
* 版 本 号:v1.0
*问题描述: 输入一个多边形的边数和边长并求出其面积。
*/
import java.util.Scanner;
public class Area {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of the polygon's sides:");
int n = input.nextInt();
System.out.println("Enter the side of the polygon:");
double s = input.nextDouble();
System.out.println("The area of this polygon is:"+area(n,s));
}
public static double area(int n,double side){
return (n*side*side)/(4*Math.tan(Math.PI/n));
}
}