Then you use padLeft to put spaces on the left of the number
to make the string a specific size overall. Then add the $ on
the left side.
If the OP is using his output on something that cannot itself right justify
the string and if he is therefore forced to use padding to do it then what
you are suggesting (and what others have suggested here) will work only if
whatever is displaying the string uses or can be set to use a monospaced
font, such as Courier. For proportionally spaced fonts, which is most fonts
in Windows, you will need to add more spaces because the width of a space
character (or a comma) is less than the width of a numeric digit, and even
then only some proportionally spaced fonts will be suitable, such as Arial
where on most systems the width of the space character is equal to the width
of a comma, which in both cases is exactly half the width of a numeric
digit. All numeric digits are the same width as each other and the comma is
the same width as the space character in many, but not all, proportionally
spaced fonts, but only in some proportionally spaced fonts, such as Arial,
is the space character exactly half the width of a numeric digit, allowing
you to add two space characters for each 'missing numeric digit' and one
space character for each 'missing comma'. Other proportionally spaced fonts
would require something other than a whole number of space characters and so
with those fonts (even with this method) if the string is displayed in
something using one of those fonts then you would get only an approximation
of the output the OP is looking for.
Mike