fork(1) download
  1. import kotlin.math.round
  2.  
  3. fun shippingCost(amount: Double, international: Boolean): Double {
  4. if (international) {
  5. if (amount <= 333.3) {
  6. return (amount / 100.0) * 15
  7. }
  8. if (amount > 333.3) {
  9. return 50.0
  10. }
  11. } else {
  12. if (amount > 75) {
  13. return 0.0
  14. }
  15. if (amount < 75) {
  16. return amount / 10
  17. }
  18. }
  19. return 0.0
  20. }
  21.  
  22. fun main(args: Array<String>) {
  23. val total = 199.9
  24. val international = true
  25.  
  26. val cost = shippingCost(total, international)
  27. println(cost)
  28. println(round(cost * 1000) / 1000)
  29. println("%.3f".format(cost))
  30. }
Success #stdin #stdout 0.09s 37688KB
stdin
Standard input is empty
stdout
29.985000000000003
29.985
29.985