fork download
  1. "use strict"
  2.  
  3. let amountStr = "15,37"
  4. let amount = amountStr.replace(",",".")
  5. amount = parseFloat(amountStr)*100
  6.  
  7. console.log("- " + Math.floor(amount / 200) + "x 2 Euro")
  8. amount = amount - Math.floor(amount / 200) *200
  9.  
  10. console.log("- " + Math.floor(amount / 100) + "x 1 Euro")
  11. amount = amount - Math.floor(amount / 100) *100
  12.  
  13. console.log("- " + Math.floor(amount / 50) + "x 50 Cent")
  14. amount = amount - Math.floor(amount / 50) *50
  15.  
  16. console.log("- " + Math.floor(amount / 20) + "x 20 Cent")
  17. amount = amount - Math.floor(amount / 20) *20
  18.  
  19. console.log("- " + Math.floor(amount / 10) + "x 10 Cent")
  20. amount = amount - Math.floor(amount / 10) *10
  21.  
  22. console.log("- " + Math.floor(amount / 5) + "x 5 Cent")
  23. amount = amount - Math.floor(amount / 5) *5
  24.  
  25. console.log("- " + Math.floor(amount / 2) + "x 2 Cent")
  26. amount = amount - Math.floor(amount / 2) *2
  27.  
  28. console.log("- " + Math.floor(amount / 1) + "x 1 Cent")
  29. amount = amount - Math.floor(amount / 1) *1
  30.  
  31. ///////////////////////////////////////////////////////////////////
  32.  
  33. let bill = 17.00
  34. let billPercent = bill * 1.12
  35. billPercent = Math.ceil(billPercent / 2.5) * 2.5
  36.  
  37. console.log("Der Gesamtbetrag beträgt " + billPercent.toFixed(2))
Success #stdin #stdout 0.02s 17028KB
stdin
Standard input is empty
stdout
- 7x 2 Euro
- 1x 1 Euro
- 0x 50 Cent
- 0x 20 Cent
- 0x 10 Cent
- 0x 5 Cent
- 0x 2 Cent
- 0x 1 Cent
Der Gesamtbetrag beträgt 20.00