- 判断是否为整数
public class Main {
public static void main(String[] args) {
for (int i = 1800; i <= 2000; i++) {
double result = i * 0.06;
if (isInteger(result)) {
System.out.println(i + " * 0.06 = " + result);
}
}
}
// Helper method to check if a double value is an integer
private static boolean isInteger(double value) {
return Math.floor(value) == value;
}
}
- math中方法 --注:后续补充编写