首页 > 其他分享 >6

6

时间:2024-09-26 11:24:14浏览次数:6  
标签: float System public Circle c1 Z2

package Z2_3_Circle;
import java. io.;
public class Z2_3_Circle{
final float PI=3.14159f;
float r;
public void setRadius(float r1)
{
r=r1;
}
public float getRadius()
{
return r;
}
public float getArea()
{
return PI
r*r;
}
public static void main(String[] args){
Z2_3_Circle c1=new Z2_3_Circle();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str=null;
float rr;
System. out.println("请输入圆的半径:");
try{
str=br.readLine();
}catch(IOException e){
e.printStackTrace();
}
rr=Float.parseFloat(str);
c1.setRadius(rr);
float Area=c1.getArea();
System.out.println("圆的半径="+c1.getRadius()+" 面积="+Area);
}
}

标签:,float,System,public,Circle,c1,Z2
From: https://www.cnblogs.com/nai-0613/p/18433106

相关文章