用於尋找圓形的周長的 Java 程式


圓形的周長是其半徑和數學常數 π 的乘積的二倍。因此,計算圓形的周長

  • 從使用者處獲取圓形的半徑。
  • 計算乘積
  • 列印最終結果。

示例:查詢圓形的周長

import java.util.Scanner;
public class CircumfrenceOfCircle {
   public static void main(String args[]){
      int radius;
      double circumference;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the radius of the circle ::");
      radius = sc.nextInt();
      circumference = Math.PI*2*radius;
      System.out.println("Circumference of the circle is ::"+circumference);
   }
}

輸出

Enter the radius of the circle::
55
The circumference of the circle is::345.57519189487726

更新時間: 2024 年 6 月 24 日

7K+ 瀏覽

職業生涯開足馬力

透過完成本課程獲取認證

開始
廣告