Java 程序查找圆的周长


圆的周长等于其半径和 PI 值的乘积的两倍。因此,为了计算圆的周长

  • 从用户处获取圆的半径。
  • 计算乘积
  • 打印最终结果。

示例:求圆的周长

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-06-24

7K+ 浏览

开启你的 职业生涯

完成课程即可获得认证

立即开始
广告
© . All rights reserved.