原代码:
public class Detec {
public static int i;
double pie=3.14;
private double r,h;
{
i++;
}
Detec(int r,int h){
this.r=r;
this.h=h;
}
public double get_v() {
return pie*r*r*h;
}
void show_v() {
System.out.println("v="+get_v());
}
public static void main(String args[]) {
Detec o1=new Detec(3,4);
Detec o2=new Detec(8,4);
Detec o3=new Detec(6,4);
System.out.println("创建个数:"+Detec.i);
o1.show_v();
o2.show_v();
o3.show_v();
}
}
运行结果不精确,请问怎样才能让他实现精确计算。