I am almost there but not quite. I need to round UP the computed tax
amount to the nearest 5 cents (or $ 0.05). I have gotten to the point
where I can round (up or down) to the nearest 5 cents. Here is my
funtion:
# computer the tax for each item given quantity, price, and percent tax
def compute_tax(quantity, price, percent_tax)
raw_value = (quantity * price * (percent_tax/100.0))
rounded_value = (raw_value * 20).round / 20.0
rounded_value
end
This does not work for the cases where the computation of raw_value
works out to something like 0.5625 for example. The function shown
above returns 0.55. I would like it to return 0.60 in such cases.
Cannot figure this out.
I am almost there but not quite. I need to round UP the computed tax
amount to the nearest 5 cents (or $ 0.05). I have gotten to the point
where I can round (up or down) to the nearest 5 cents. Here is my
funtion:
# computer the tax for each item given quantity, price, and percent tax
def compute_tax(quantity, price, percent_tax)
raw_value = (quantity * price * (percent_tax/100.0))
rounded_value = (raw_value * 20).round / 20.0
rounded_value
end
This does not work for the cases where the computation of raw_value
works out to something like 0.5625 for example. The function shown
above returns 0.55. I would like it to return 0.60 in such cases.
Cannot figure this out.