还是JAVA的问题

来源:百度知道 编辑:UC知道 时间:2024/06/17 00:19:54
class Box{
double width;
double height;
double depth;

double volume( ){
return width * height * depth;
}
}

class BoxDemo4{
public static void main(String args[]){
Box mybox1 = new Box( );
Box mybox2 = new Box( );
double vol;

mybox1.width = 10;
mybox1.height = 20;
mybox1.depth = 15;

mybox2.width = 3;
mybox2.heigth = 6;
mybox2.depth = 9;

vol = mybox1.volume( );
System.out.println("Volume is" + vol);
vol = mybox2.volume( );
System.out.println("Volume is" + vol+);
}
}

编译一下就可以找到问题啊!
你有点粗心哦!
class Box{
double width;
double height;
double depth;

double volume( ){
return width * height * depth;
}
}

class BoxDemo4{
public static void main(String args[]){
Box mybox1 = new Box( );
Box mybox2 = new Box( );
double vol;

mybox1.width = 10;
mybox1.height = 20;
mybox1.depth = 15;

mybox2.width = 3;
//mybox2.heigth = 6;
mybox2.height = 6;
mybox2.depth = 9;

vol = mybox1.volume( );
System.out.println("Volume is" + vol);
vol = mybox2.volume( );
//System.out.println("Volume is" + vol+);
System.out.println("Volume is" + vol);
}
}