Hi,
Let's say x=12.34, y=567.89, z=6.38, and we want the output this way:
_____$12.34
____$567.89
______$6.38
right-aligned with the decimal point lined up (where the ___ are spaces)
In other words, all the numbers are right-aligned and immediately following "$". How to do that if you don't know what values x, y, z will have?
Is "... << right << setw(..) << ..." the way to go? But obviously the following won't work:
cout << right << setw(10) << "$" << x;
cout << right << setw(10) << "$" << y;
cout << right << setw(10) << "$" << y;
because that gives
_____$12.34
_____$567.89
_____$6.38
(keep in mind you can't adjust setw(9) or setw(8) accordingly because you don't know beforehand what values the variables will take)
Again, thanks in advance for any help! This forum is awesome!