I'm trying format a float to have a dollar sign in front of the number. Currently I'm trying to get it to print 150 spaces from the left side.
System.out.printf("%150.2f", orderTotal);
This is what I'm using but I can't figure out where to put the $
I guess I could make the entire thing into a String, but I was wondering if there is a way to do what I'm looking for?
How about
System.out.printf("%150s", String.format ("$%.2f", orderTotal));
System.out.printf("%150s$%.2f", "", orderTotal);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With