Description
Give you the radius of a circle,caculate its area,PI=3.141592653。
Input
The first line of the input is a positive integer N,then follows N lines,each line is a real number represent the radius of the circle.
Output
Output contains N lines,for each line of the input you should output one line, Case K: S,and K(count from 1)represents the number of the circle and S is the area.Keep two digits after the decimal point.
Sample
Input
3
1
2
3
Output
Case 1: 3.14
Case 2: 12.57
Case 3: 28.27
import java.util.Scanner;
class Math1 {
final double PI=3.141592653;
public double circle(int n) {
double x;
x=n*n*PI;
return x;
}
}
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Math1 math = new Math1();
int n=input.nextInt();
for(int i=1;i<=n;i++) {
System.out.println("Case "+i+": "+String.format("%.2f", math.circle(input.nextInt())));
}
input.close();
}
}
本文提供了一个简单的Java程序,用于计算给定半径的圆的面积。输入为一系列圆的半径,输出则是每个圆对应的面积,精确到小数点后两位。
672

被折叠的 条评论
为什么被折叠?



