im getting wrong results, if tendered was declared 29.26 and purchase was 100. i should be getting 7074 but im getting 7000. anyone know where it went wrong?Code:change_in_cents = (int)(floor(tendered - purchases)* 100.0 + 0.5);
Printable View
im getting wrong results, if tendered was declared 29.26 and purchase was 100. i should be getting 7074 but im getting 7000. anyone know where it went wrong?Code:change_in_cents = (int)(floor(tendered - purchases)* 100.0 + 0.5);
I think you might be misunderstanding the use of the floor function. Take a look at this link, it gives you some inputs and what their output would be when given to the floor function.
Also, tendered being 29.26 and purchases being 100 would give you a negative number, take a look that if that is not what you intended.
http://www.cplusplus.com/reference/c...y/cmath/floor/