以下是我的代码(部分代码)。我的问题是,我能否在前面添加“00”使前9个数字显示,并在10-99的数字前添加“0”。
我必须显示所有360个月付款,但如果月份数字长度不同,就会出现输出文件移动到右侧并偏移输出外观的情况。
System.out.print((x + 1) + " "); // the payment number
System.out.print(formatter.format(monthlyInterest) + " "); // round our interest rate
System.out.print(formatter.format(principleAmt) + " ");
System.out.print(formatter.format(remainderAmt) + " ");
System.out.println();
结果:
8 $951.23 $215.92 $198,301.22
9 $950.19 $216.95 $198,084.26
10 $949.15 $217.99 $197,866.27
11 $948.11 $219.04 $197,647.23
我希望看到的是:
008 $951.23 $215.92 $198,301.22
009 $950.19 $216.95 $198,084.26
010 $949.15 $217.99 $197,866.27
011 $948.11 $219.04 $197,647.23
你需要查看我这个类的哪些其他代码以便帮助呢?
009 $950.19 $216.95 $198,084.26
010 $949.15 $217.99 $197,866.27
011 $948.11 $219.04 $197,647.23 008 $951.23 $215.92 $198,301.22 - RazorSharp