找到圓的面積的 Java 程式


圓的面積是其半徑的平方和圓周率的值的乘積,因此,要計算矩形的面積

  • 獲得圓的半徑。
  • 計算半徑的平方。
  • 計算圓周率值和半徑的平方值的乘積。
  • 列印結果。

示例

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

更新於: 2020 年 3 月 13 日

19K+ 瀏覽量

開始你的 職業生涯

完成課程獲取認證

開始
廣告
© . All rights reserved.