此方法有效,但不显示奇数
public class OddEvan_checker {
private int number;
public void setNumber(int number) {
number = number;
}
public int getNumber() {
return number;
}
public int calculate() {
if (number % 2 == 0) {
System.out.println(number+"even");
} else {
System.out.println("odd ");
}
return number;
}
}
答案 0 :(得分:0)
public class OddEvenChecker { // Also consider renaming the typo and avoiding snake_case
private int number;
public void setNumber(int number) {
number = number;
}
public int getNumber() {
return number;
}
public int calculate() {
if (number % 2 == 0) {
System.out.println(number+"even");
} else {
System.out.println(number+"odd "); // add the number here to solve the issue
}
return number;
}
}