我如何根据使用的纸张总数知道我使用了多少 Ink
How will I know how much Ink I used based on the total papers used
所以我想做一个 IF 语句,它将 return 基于所用纸张的总墨水消耗量。
一 (1) 盒墨水 = 9,600 张纸
正确的逻辑是什么?
这是我的代码:
if ($total_papers <= 9600) {
//the number of box will increment
//so if the total is 19,200 it should return 2 boxes.
} else{ //not more than 1 box }
一个if
语句不能return任何东西。如果要根据使用的纸张数量来计算墨水消耗量,只需做一个除法,然后再取一个上限:
$ink = ceil($total_papers/9600);
这样就可以得到使用的墨盒数量。然后你可以在 if
语句(或任何你喜欢的地方)
中使用 $ink
所以我想做一个 IF 语句,它将 return 基于所用纸张的总墨水消耗量。
一 (1) 盒墨水 = 9,600 张纸
正确的逻辑是什么?
这是我的代码:
if ($total_papers <= 9600) {
//the number of box will increment
//so if the total is 19,200 it should return 2 boxes.
} else{ //not more than 1 box }
一个if
语句不能return任何东西。如果要根据使用的纸张数量来计算墨水消耗量,只需做一个除法,然后再取一个上限:
$ink = ceil($total_papers/9600);
这样就可以得到使用的墨盒数量。然后你可以在 if
语句(或任何你喜欢的地方)
$ink