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

更新於: 13-Mar-2020

19K+ 瀏覽次數

啟動你的 職業

完成課程以獲得認證

開始
廣告