/* 
使用三部曲。 
第一步: 在class之前  导包   
import java.util.Scanner; 
第二步: 在main方法里 创建对象 
Scanner sc = new Scanner(System.in); 
第三步: 调用 格式 
int number = sc.nextInt(); 
练习: 输入一个月份,输出对应的 季节。 
 
*/ 
 
import java.util.Scanner;  // 导包 
class ScannerDemo 
{ 
        public static void main(String[] args) 
        { 
                Scanner sc = new Scanner(System.in);//创建对象 
                System.out.println("请输入月份");//输入提示 
                int month = sc.nextInt();//调用 
                String Season ; 
                if (month >=3 && month <6) 
                { 
                        Season = "春季" ; 
                } 
                else if (month >= 6 && month < 9) 
                { 
                        Season = "夏季" ; 
                } 
                else if (month >= 9 && month < 12) 
                { 
                        Season = "秋季" ; 
                } 
                else if (month == 12 || month <= 2 && month > 0) 
                { 
                        Season = "冬季" ; 
                } 
                else  
                { 
                        Season = "错误的月份"; 
                } 
                System.out.println(month+"月是"+Season); 
        } 
} 
 
 |