hi cptntan, I'm new to this too, so forgive me if this doesn't work, but I think that you could:
multiply the input by 100
change it to int form
keep adding 1 to it until it is divisible by 10
change it back to double form
then divide it by 100 so you get an answer that makes sense
you could use code that looks something like this
theInt = static_cast<int>(money * 100);
while(theInt % 10 != 0) {
theInt++; }
result = static_cast<double>(theInt / 100); |
where money is the original input, theInt is the multiplied form of money, and result is your rounded answer
given, this code only works if your answer goes to 2 or less decimal places, but if you are dealing with money, it works perfectly.
I don't like to change it from double to int and back to double, but that is the easiest way I can think of.