3.(1) Use an infinite loop in ‘main’ to get 3 ‘double’-type data returned from a method ‘double myGetDouble() {…}’, as the values for the length, width and depth of a container.
(2) Use ‘0’ as the sentinel input to escape from the infinite loop.
(3) Use another method ‘double myVolume(…) {…}’ to receive the 3 values as parameters to calculate the volume, and return the result to ‘main’ for printing. 
(4) All printed floats should keep only 2 decimal places (i.e. 2 fractional digits). Your code should produce results as the following screenshot. [20 points]
public static void main(String[] args){首先是类的main方法,(2)和(3)的打印需要的功能都是这里来执行的
        for(循环几次看你,如果循环到0即停止循环){
         
         在main中执行double myGet.(){...}得到3个参数
 
          调用double myVolume(double a,b,c){...}方法进行乘积计算,记得将3个参数传进去
 
          这里执行好上面代码后会得到一个double参数,用这个参数进行打印
 
         System.out.println(这里放返回数据);
         }
}double myGet.(...){

     return a,b,c;这里返回3个参数 提前定义double,然后用Math.random()来返回一个double类型的数据
 
}double myVolume(double a,b,c){

     double d = a*b*c;(注意,题里面给的这个double相乘会出现小数点不精确的情况,你自己知道就好了)
 
      return d;(然后返回计算好的数)
}

解决方案 »

  1.   

        
        public static void main(String[] args) {
            for (int i = 0; i < 10; i++) {
                double var = myVolume(myGet(), myGet(), myGet());
                System.out.println(var);
            }
        }
        public static double myGet() {
            return Math.random();
        }    public static double myVolume(double a, double b, double c) {
            return a * b * c;
        }这个意思? Math.random(), 返回0到1的小数
      

  2.   

    楼主的英语是有多差!题目帮你翻译如下:
    (1) 在main中使用一个无限循环,以得到由方法“double myGetDouble() {...}”返回的3个double类型数据,这三个数据是容器的长、宽、深度。
    (2) 使用“0”作为跳出无限循环的守护输入条件。
    (3) 用另一个方法“double myVolume(...) {...}”来接收3个参数,用于计算(容器的)体积,并且将计算结果返回给main用于打印。
    (4) 所有被打印的浮点数应该保持2位消暑。你的代码应该产生如下图截屏所示的结果。