输入圆的半径,得出圆的周长和面积JAVA代码
时间: 2023-09-15 11:20:34 浏览: 97
java代码实现求圆的周长和面积方法示例
import java.util.Scanner;
public class Circle {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入圆的半径:");
double radius = scanner.nextDouble();
double perimeter = 2 * Math.PI * radius;
double area = Math.PI * radius * radius;
System.out.println("圆的周长为:" + perimeter);
System.out.println("圆的面积为:" + area);
}
}
阅读全文