編寫一個java函式,動態的指定貨物的長,寬,高,計算一個倉庫貨位最多存放多少貨物,設貨位大小為:

  • 作者:由 匿名使用者 發表于 歷史
  • 2023-01-26

編寫一個java函式,動態的指定貨物的長,寬,高,計算一個倉庫貨位最多存放多少貨物,設貨位大小為:熱心問友2017.03.07 回答

public class ZhiDao4 {

static int avgLength = 500;

static int avgWidth = 400;

static int avgHeight = 400;

public static void main(String[] args) {

System。out。println(store(100,200,200));

}

public static int store(double length,double width,double height) {

int a = (int) (avgLength / length);

int b = (int) (avgWidth / width);

int c = (int) (avgHeight/height);

if (a > b) {

a = b;

}

if (a > c) {

a = c;

}

return a;

}

}

Top