我有一种方法,在计算费用并向其中添加费用后,将总价格打印为双倍数。字符串格式错误
public static String printWarehouseCharge(Warehouse w[])
{
String wc = "";
for(int i=0; i < 4; i++)
{
// method that calculates charge and returns a double
double warehouseCharge = w[i].calculateWarehouseCharge();
//here the calculateTransportFee method adds a fee and returns the total to be printed
wc = wc+String.format("$%,.2f", w[i].calculateTransportFee(warehouseCharge) +"\n");
}
return wc;
}
很抱歉,我一直收到格式错误:IllegalFormatConversionException
。 任何人都可以帮助我吗?
简单你的'calculateTransportFee'方法不返回正确的浮动。 – erencan