import java.util.*;
public class ee {public static void main(String []agrs) {
Scanner sc=new Scanner(System.in);
System.out.println("告诉我你的宽?");
double wa=sc.nextDouble();
System.out.println("告诉我你的长?");
double da=sc.nextDouble();
System.out.println("告诉我你的高?");
double ha=sc.nextDouble();
parallelepiped wm=new parallelepiped();
wm.setwidth(wa);
wm.setdepth(da);
wm.setheight(ha);
System.out.println("面积="+wm.getsurface()+"体积="+wm.getvolume()+"周长="+wm.getlength());
}
}
class parallelepiped{
private double width,depth,height;
public static void setwidth(double wa) {
double width=wa;
}
public double width() {
return width;
}
public static void setdepth(double da) {
double depth=da;
}
public double getdepth() {
return depth;
}
public static void setheight(double ha) {
double height=ha;
}
public double getheight() {
return height;
}
public double getsurface() {
return width*depth;
}
public double getvolume() {
return width*depth*height;
}
public double getlength() {
return (width+depth)*2;
}
public String tostring() {
return "面积是="+getsurface()+"体积是="+getvolume()+"周长是="+getlength();
}
}
为什么我输入长,宽,高的数值后,最后计算结果都是0.0?
比如用户回答宽是2,长2,高3,那么面积不可能算出来是0.0的啊
酒木君