public static void printNum(double num) {
double x = Math.floor(num);
Double b = num - x;
char[] c = b.toString().toCharArray();
String s = b.toString();
System.out.print(num+"小数点后两位是:");
for (int i = 0; i < c.length; i++) {
if (i < 3) {
sop(c[i]);
} else if (i == 3 && c[i + 1] >= 53) { //整形数字5转换成char型值为53
c[i] += 1;
sop(c[i]);
break;
} else if (i == 3) {
sop(c[i]);
break;
}
}
System.out.println("(四舍五入)");
}
public static void sop(Object obj) {
System.out.print(obj);
}
}