I am looking to make a script that does a calculation for me.
The user is to enter two variables, height (H) and width (W), click "calculate" and the value will appear, hopefully on the same page.
The formula will be (((H*W)+150)*1.65) (pretty easy)
However, I would like it to round up to the nearest 10th. So if the value comes out to 411 I would like it to display 420. If the solution is 579 it will round up to 580.
Sounds easy but I am not sure where to start.
Any guidance will be appreciated.
Thanks!!!!
It IS possible to do this the old fashion way.
Lets say you start off with 514 and you want to end up with 520
What you do is divide by 10:
51.4
do the round and add one
round(51.4) will give you 51
add one will give you 52
then multiply by ten!
that will give you a round up to 10.
if you want to round to 100, just divide and multiply by 100.
The other thing to consider is what if you get 500, do you want 510?
The way you can check for this is to divide by 100 and see if you get an integer number. 500/100 = 5 (hint: check for float() or presence of "." (decimal) in it.
514/100 will of course give you 5.14.
Hope that helps, good luck.