Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Padding decimals in Java

Name: Anonymous 2013-02-03 4:44

How can I pad a double with both trailing zeros (two places, for money) and leading spaces before the $ to align the decimal places?
I want my list to look like:

$###.##
$###.##
_$##.##
__$#.##
__$0.##
__$0.00

As the value decreases. The underscores should be spaces, of course. I wasn't sure if they would appear or be deleted in the post.

Also, I changed a function somewhere and a series of print functions decided to start tabbing every fucking word so they're all spread out and I can't find anything wrong with the code. Any ideas?

System.out.print("\n\nWhat    would    you like    to    do?\n1. Calculate    the Monthly    Payment for    a fixed rate, fixed term loan.\n");
            System.out.print("2.    Calculate the number    of    Months to pay off    a loan with    a fixed monthly payment.\n");
            System.out.print("\nPlease    enter    the number of your selection:    ");

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-02-03 7:38

http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html

If you're needing older than Java 1.5 compatbility (not unusual for enterprise stuff), then you'll need to go find the printf replacement somewhere else.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List