help please my rounding off Counting Method ()
I created 5 functions to give me proper change sometimes it gives me proper change others times it won't example 1.88 should give 1 dollars,3 quarters, 1 dimes 0nickles 3 pennies instead it gives me 1 dollars 3 quarters 1 dimes 1 nickles 3 pennies it seam like my rounding is off also if you can help me plurise it that would be greatly appreciated. fun main(args: Array<String>) { var change = 1.88 println("" + dollars(change).toInt() + " dollars") println("" + quarters(change).toInt() + " quarters"); println("" + dimes(change).toInt() + " dimes"); println("" + nickles(change).toInt() + " nickles"); println("" + pennies(change).toInt() + " pennies"); } fun dollars(totalDollars: Double): Double { return Math.floor(totalDollars / 1) } fun quarters(totalQuarters: Double):Double { return ((totalQuarters % 1) / .25).toDouble(); } fun dimes(totalDimes: Double): Double { return Math.round(totalDimes % 1 % .25 / .10).toDouble(); } fun nickles(totalNickles: Double): Double { return Math.round(totalNickles % 1 % .25 % .10 / .05 ).toDouble(); } fun pennies(totalPennies: Double): Double { return Math.round(totalPennies % 1 % .25 % .10 % .05 / .01).toDouble(); }