常用的包和类
Scanner :提供input功能
import java.util.Scanner; public class Demo2 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("请输入一个非0的数字:"); int num = input.nextInt(); String result=(num%2==0)?"偶数":"奇数"; System.out.println(num+ "是" + result); } }