Java 程式以找出圓的面積
圓的面積是其半徑的平方和 PI 值的乘積,因此,要計算矩形的面積
- 獲取圓的半徑。
- 計算半徑的平方。
- 計算 PI 值和半徑平方值乘積。
- 列印結果。
示例
import java.util.Scanner;
public class AreaOfCircle {
public static void main(String args[]){
int radius;
double area;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the radius of the circle ::");
radius = sc.nextInt();
area = (radius*radius)*Math.PI;
System.out.println("Area of the circle is ::"+area);
}
}輸出
Enter the radius of the circle :: 55 Area of the circle is ::9503.317777109125
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP