class yuan
{
int b;
final double PI=3.1415926;
int mianji()
{
return (int)(PI*((double)b)*((double)b);
}
int zhouchang()
{
return (int)(2*((double)b)*PI);
}
public static void main( String[] args)
{
yuan y1=new yuan();
yuan y2=new yuan();
y1.b=2;
System.out.println("mianji of yuan="+y1.mianji());
System.out.println("zhouchang of yuan="+y1.zhouchang());
y2.b=4;
System.out.println("mianji of yuan="+y2.mianji());
System.out.println("zhouchang of yuan="+y2.zhouchang());
}
}
[此贴子已经被作者于2007-9-22 2:52:29编辑过]