我做了一個計數器,我使用PHP和幾乎一切都很好,但我發現它的一個小錯誤。我的PHP代碼沒有得到更正
我在櫃檯前兩步就行了,那就是$bid
和。
我最後的結果$pay
應該是:8138 + 814 + 448 = 9400
,但它給我$9,399
我的輸出是:
Value $8,138 bid $814 tax $448 You Pay $9,399
Value $8,952 bid $895 tax $492 You Pay $10,339
Value $9,847 bid $985 tax $542 You Pay $11,373
這裏是我的PHP提前
<?php
$i = 0;
$v = 8138; // value : 8138
do {
$i++;
$bid = $v/10; // output : $814
$ftax = $v + $bid;
$stax = $ftax/20; // output : tax $448
$pay = $v + $bid + $stax; // 8138 + 814 + 448 = 9400
echo "Value $" . number_format($v) . " bid $" . number_format($bid) . " tax $" . number_format($stax) . " You Pay $" . number_format($pay) . "<br />";
$v = $v * 1.1;
} while ($i <= 2);
?>
感謝: )
我認爲你正在失去沿途有一些小數.... – thatidiotguy
哈啊,我會盡我的計算器 –
呀$競價,它和$ STAX小數。如果您不想使用小數,則需要將它們向上或向下舍入。 – Pitchinnate