publicvoidcalcuteZC(){double zC =2* pi *this.radio;double result =newBigDecimal(zC).setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
System.out.println("圆的周长为:"+result);}
四舍五入BigDecimal废话不多,直接代码,可double,可float public void calcuteZC(){ double zC = 2 * pi * this.radio; double result = new BigDecimal(zC).setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue(); System.out.println("圆的周长为:"+result); }