I want to write some code to determine if I need to write "Quarter" or "Quarters" depending on the amount.
Up to now I have the following code:
fun main(args: Array<String>) {
var changeDue = 1.22;
Change(changeDue);
}
fun Change(changeDue: Double) {
var quarters = Math.floor(changeDue / 1.0);
print(Math.round(quarters * 4) / 1)
if (quarters <= 2)
println(" Quarters")
else if (quarters > 2)
println(" Quarter")
println("")
println(".22 remain")
}
Is it correct?
Is there a better way to achieve it?