수학에서 "π"는 무엇입니까?
22/7이고 3.14159라는 상수 값으로 표시되는 원주와 지름의 비율을 수학에서 "파이"라고 합니다.Java에서 Math.PI는 무엇입니까?
Math.PI는 Java의 정적 최종 이중 상수이며 π Mathematics와 동일합니다. java.lang.Math 클래스 에서 제공하는 Math.PI 상수는 원의 면적 및 원주 또는 구의 표면적 및 부피를 찾는 것과 같은 여러 수학 및 과학 계산을 수행하는 데 사용됩니다. 실생활에서 "pi" 양은 끝없이 사용되는 기본적인 위치를 가집니다. 그들 중 일부는 아래에 나열되어 있습니다.- 항공우주 설계자는 파이를 사용하여 항공기 동체 면적을 계산합니다.
- 의학은 파이를 사용하여 눈의 구조를 분석함으로써 파이의 이점을 얻습니다.
- 생화학자들은 파이를 사용하여 DNA 구성을 연구합니다.
- 통계학자들은 pi를 사용하여 국가의 인구 역학을 예측합니다.
- Pi는 현재 우리가 가지고 있는 GPS(Global Positioning System)의 핵심 가치를 가지고 있습니다.
예
Java에서 Math.PI 의 값을 가져오고 사용하는 방법을 알아보려면 다음 실행 가능한 예제를 살펴보겠습니다.
public class PiInJava {
public static double circumferenceOfCircle(int radius) {
return Math.PI * (2 * radius);
}
public static double areaOfCircle(int radius) {
return Math.PI * Math.pow(radius, 2);
}
public static double volumeOfSphere(int radius) {
return (4 / 3) * Math.PI * Math.pow(radius, 3);
}
public static double surfaceAreaOfSphere(int radius) {
return 4 * Math.PI * Math.pow(radius, 2);
}
public static void main(String[] args) {
int radius = 5;
System.out.println("Circumference of the Circle = " + circumferenceOfCircle(radius));
System.out.println("Area of the Circle = " + areaOfCircle(radius));
System.out.println("Volume of the Sphere = " + volumeOfSphere(radius));
System.out.println("Surface Area of the Sphere = " + surfaceAreaOfSphere(radius));
}
}
산출
원의 둘레 = 31.41592653589793 원의 면적 = 78.53981633974483 구의 부피 = 392.6990816987241 구의 표면적 = 314.1592653589793
GO TO FULL VERSION