I'm in my first programming class using Java, and I was told that this site is a good source for programming help.
I'm in a bit of a hard spot right now, because I'm having trouble putting numbers in U.S. currency and also aligning them by their decimal point. The assignment itself has the user entering an initial deposit and an interest rate. The program then stops when your initial deposit has doubled. Everything is working as expected, but I can't get the decimals to align.
while(Total < Deposit*2 )
{
Total = Total*(InterestRate/100+1.00);
Year = (Year + 1);
System.out.printf("%-16s %-24s %-15s\n", Year + ".", fmt.format((Total-Deposit)), fmt.format(Total));
}
Spacing and putting it into the currency format isn't an issue, but as of right now it aligns the dollar sign. I personally think it looks better, but the professor said he would like the decimal points aligned and now I'm dead set on figuring it out.
I've seen
String.format("%8.3f", number)
But I don't know how to get it incorporate it into my current code.