我正在尝试像这样对齐我的输出:
Full Name Total Sales
========= ===========
John Smith 619.50
Mary Willow 514.50
Sallie Smite 519.50
Tom Andrews 55.00
Norman Bates 366.00
Horace Williams 301.00
Anne Whitney 426.37
Wallie Jawie 647.00
Marie Bunker 63.00
Mopsie Bear 1582.00
Stephen Andrews 265.00
Stacie Andrea 265.00
Last Name 463.00
我正在使用此代码,但对齐总是关闭
// For loop
System.out.printf("%s %s %.2f %n " , list[i].getFirstName() , list[i].getLastName(), list[i].getTotalSales() )
这是我得到的结果。如何使总销售额保持一致?另外第二个输出在名字前面有一个空格,我怎样才能摆脱它?
Full Name Total Sales
========= ===========
John Smith 619.50
Mary Willow 514.50
Sallie Smite 519.50
Tom Andrews 55.00
Norman Bates 366.00
Horace Williams 301.00
Anne Whitney 426.37
Wallie Jawie 647.00
Marie Bunker 63.00
Mopsie Bear 1582.00
Stephen Andrews 265.00
Stacie Andrea 265.00
Last Name 463.00