📜  使用 mod 运算符在 Java 中编写奇数甚至偶数程序 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:11.155000             🧑  作者: Mango

代码示例1
import java.util.Scanner;public class Main{public static void main(String[] args){Scanner reader = new Scanner(System.in);System.out.print("Enter a number: ");int num = reader.nextInt();if(num % 2 == 0)System.out.println(num + " is even");elseSystem.out.println(num + " is odd");}}