Java 中如何将 BigDecimal 乘以整数?我试过这个,但它不正确。
import java.math.BigDecimal;
import java.math.MathContext;
public class Payment {
int itemCost;
int totalCost = 0;
public BigDecimal calculateCost(int itemQuantity,BigDecimal itemPrice){
itemCost = itemPrice.multiply(itemQuantity);
totalCost = totalCost + itemCost;
return totalCost;
}