我需要创建一个名为“ParticleDropClass”的“主”类。此类的目的是计算一个巨大的物体落到装有粘性液体的容器底部所需的时间。
public class ParticleDropClass {
double m;
double d;
double z;
double t;
double v;
public ParticleDropClass (double x, double y){x=m;y=d;} // creating a constructor
public final double g= 9.81 ;//constants
public final double h = 10.0;//constants
public void drop(double dt ){
t=0;v=0;
double z=h;// intial height at 10m
while ( z>= 0.0){
double a= (d*v*v)/m-g;// formula for body's acceleration
double dv= a*dt;
double dz=v*dt ;
double z1= z+dz;
double v1= v+dv;
double t1=t+dt;
t1=t;
v1=v;
z1=z;
}
System.out.println("t ="+t +"dt="+t+"s"+ "\n"+"final v="+v+"m/s" );
}
public static void main(String[] args) {
double m=4.3;double d=2.5 ;
ParticleDropClass b= new ParticleDropClass(m,d);// for an object of mass 4.3 and 2.5 , at height 0.5 I create a object .
b.drop(0.5);
}
}
但是我运行上面的代码没有任何反应,为什么?