Currency Exchange Exercise

I’m passing all but 3 of the tests, and all of the 3 failing tests involve the exchangeable_value() method, so I’m pretty sure the rest of my methods are okay.

Here’s what I’ve written:

function exchangeable_value(budget, exchange_rate, spread, denomination)
    println("*******************")
    exchange_fee = (spread / 100) * exchange_rate
    println(exchange_fee)
    new_exchange_rate = exchange_rate + exchange_fee
    println(new_exchange_rate)
    num_bills = get_number_of_bills(budget, denomination)
    val_bills = get_value_of_bills(denomination, num_bills)
    final_val = exchange_money(val_bills, new_exchange_rate)
    return round(final_val)
end

I’m not sure what I’m missing

get_number_of_bills() rounds down to a whole number of bills.

We should do the floating point calculations using new_exchange_rate before get_number_of_bills() is called.

What do we do to the budget amount? Do we need to multiply it by (1 - new_exchange_rate)?

You use the budget and new exchange rate to get the converted/exchanged budget/amount. Then that’s the number you use to get the bills.

Oh I understand now; I have to do the exchange_money call before the number_of_bills and value_of_bills calls. Thank you!

2 Likes

I don’t know if you looked at the hints (behind the “Get help” button for users of the online editor, or called hints.md for a CLI download?

These exercises were only made public 10 days ago, so please let us know if you read the docs and found them inadequate. The authors like to get an idea of what works and what needs improving, while hoping that most things are in the “works” category!