fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.math.BigDecimal;
  7. import java.math.RoundingMode;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. BigDecimal unspent =
  15. new BigDecimal(-45).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
  16. BigDecimal effectiveBudget = new BigDecimal(5).divide(new BigDecimal(100), 2,
  17. RoundingMode.HALF_UP);
  18. BigDecimal maxTargetToBudgetRatio = new BigDecimal(1.1D).setScale(2, RoundingMode.HALF_UP);
  19. BigDecimal tempEnforcedBudget1 = maxTargetToBudgetRatio.multiply(effectiveBudget);
  20. tempEnforcedBudget1 = tempEnforcedBudget1.setScale(2, RoundingMode.HALF_UP);
  21. BigDecimal tempEnforcedBudget2 = effectiveBudget.add(unspent
  22. .divide(new BigDecimal(10), 3,
  23. RoundingMode.HALF_UP));
  24. System.out.println(effectiveBudget+","+unspent
  25. .divide(new BigDecimal(10))+","+tempEnforcedBudget2);
  26.  
  27. }
  28. }
Success #stdin #stdout 0.21s 58380KB
stdin
Standard input is empty
stdout
0.05,-0.045,0.005