如何在 Java 中将 BigDecimal 乘以整数
2022-08-31 15:00:06
如何在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;
}