(1)
import
java.text.io;
DecimalFormat df
=
new
DecimalFormat(
"
#.00
"
);
System.out.println(df.format(d1));
System.out.println(df.format(d2));
public
int
getRound(
double
dSource)
...
{


int iRound


//BigDecimal的构造函数参数类型是double


BigDecimal deSource = new BigDecimal(dSource);


//deSource.setScale(0,BigDecimal.ROUND_HALF_UP) 返回值类型 BigDecimal


//intValue() 方法将BigDecimal转化为int


iRound= deSource.setScale(0,BigDecimal.ROUND_HALF_UP).intValue();


return iRound;


}





(2)



























