如何圓一個數字,2位小數,例如 12.72 --> 12.70
12.76 --> 12.75
例如 decimal from 1.01 to 1.02 will round off to 1.00
decimal from 1.03 to 1.04 will round off to 1.05
decimal from 1.06 to 1.07 will round off to 1.
我對Java相當陌生,而且我最近編寫了一個代碼,用於計算您需要支付多少金額項目。它運作良好;我唯一的問題是,只要沒有百分之一的虧損(例如4.60美元),它就會下降到十分之一(4.6美元)。 如果有人知道如何解決這個問題,我將非常感激。我有下面的代碼。 class Main {
public static void main(String[] args) throws IOExceptio