Hi I'm a begginer of C++ and I have been trying to make my program to round off the number for money. For example $12.65515 then it will become $12.66 and $0.01 will be round off. I don't know how to do that I have been searching everywhere and I couldn't find it. Another thing is i want my program to show if the money have been round up/off like Total $12.66, Rounding -$0.01. Thank for your help.
if you wanted to find the difference of the rounded number and original you'd want to use a std::stringstream, that way you can set the precision push the number in and then read it out again into a second float value. then you can take the numeric difference and cout all 3 values...
I'm not 100% sure stringstreams support precision but I'm pretty sure it's a stream universal ability. Also I don't off the top of my head know the call to force the stringstream to clear its contents if any, but you'd want to put that between lines 17 and 18.