用于寻找圆形的周长的 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+ 浏览

职业生涯开足马力

通过完成本课程获取认证

开始
广告
© . All rights reserved.