I have a problem with setw inside my while loop. When I run it, the first 30 loops are fine. On the 31st loop, there is an extra space for no reason. Anyone know why?
When I get rid of the dollar sign before principalpaid, principal works fine. When I add the dollar sign in, principal gets a space added to it every thirty loops.
I do not have enough information to test the loop, but I am thinking that the "setw()" before principalpaid and principal may be to small. Or you might try putting the "setw()" on the right side of "$ " and see what happens.
setw only applies to the next thing that is outputted. If you want to set the width for both the dollar sign and the value combined I think you will have to first convert them to a string so that you can output them both in one operation.