我有一个函数i.e applyCredit(double amount )
如果我将此功能称为applyCredit(inputAmount)
inputAmount
多次更新,和i.e ####.00
采用双精度格式amount
现在的问题是:amount
的格式始终为2精度,或者可能会更改为double
答案 0 :(得分:0)
只要它能够适应"输入可以带或不带小数
public static void main(String[] args) {
System.out.println(applyCredit(2));
System.out.println(applyCredit(2.66));
System.out.println(applyCredit(2.72251));
}
static private double applyCredit(double amount ){
return amount*2;
}
将打印: 4.0,5.32,5.44502