+ 1

Im trying to create a method to count exact change can someone help ?

I'm trying to create a method called quarters(). When I pass any double value (ChangeDue) into the method, I want to know precisely how many quarters there are as well as the partial change returned. fun main(args: Array<String>) { var changeDue = 4.75; amount (changeDue); } fun amount(changeDue: Double){ var dollars = Math.floor(changeDue ,1.0); var changeDue.0 = changeDue - (dollars -1.0); var quarters = Math.floor(changeDue, 0.25); var changeDue.1 = changeDue - (quarters - 0.25); var dimes = Math.floor(changeDue , 0.10); var changeDue.2 = changeDue - (dimes - 0.10); var nickel = Math.floor(changeDue , 0.05); var changeDue.3 = changeDue - (nickel - 0.05); var penny = changeDue; return changeDue; }

16th Mar 2022, 2:03 AM
Mikey
1 Answer
+ 3
Hello Mikey, You can add Kotlin in the post's tags to improve language scope clarity ☝
16th Mar 2022, 8:42 AM
Ipang