import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Round{
public double diameter(double d){
return d*2;
}
public double perimeter(double d){
return 2*d*3.14;
}
public double area(double d){
return d*d*3.14;
}
}
public class OperateDemo{
public static void main(String args[]){
Round round=new Round();
double temp=0.0;
System.out.print("请输入圆的半径-->");
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
String str=null;
try{
str=buf.readLine();
}catch(IOException e){
e.printStackTrace();
}
temp=Double.parseDouble(str);
System.out.print("改圆的直径为-->"+round.diameter(temp)+"\n"+
"改圆的周长为-->"+ round.perimeter(temp)+"\n"+
"改圆的面积为-->"+ round.area(temp));
}
}
楼主别忘了给分啊~~~
追问确定对吗,有运行结果没
追答没问题的,无语了,你不信运行看下。