In my program I have a simple Coin Adding calculator. In this program at the end it displays a value of money that the coins add up to.
My issue begins here. When the currency or the double value ends up being any number where the cent value ends in a 0, it excludes it.
For example: I want it to show You have $4.50! Instead if it ends in a 0 it will print You have $4.5
How can I make it print the 0 as well. If it's something that ends in any number other than 0 it prints it.
Thanks!
fun main(){
val Quarter1 = quarter()
val Dime1 = dime()
println("How many Quarters do you have?")
var quarterQuan = readLine()!!.toDouble()
println("How many Dimes do you have?")
var dimeQuan = readLine()!!.toDouble()
println("")
println("You have {$quarterQuan} Quarters and {$dimeQuan} Dimes!")
var quarterTotal = quarterQuan * Quarter1.quarterVal
var dimeTotal = dimeQuan * Dime1.dimeVal
var cashTotal:Double = quarterTotal + dimeTotal
var roundCashTotal:Double = String.format("0%f",
cashTotal).toDouble()
//cashTotal = Float.toString()
println("Your total cash value for change is \$ ${roundCashTotal} ")
}
class quarter{
val quarterVal = .25
}
class dime{
val dimeVal = .10
}