/*
* 試撰寫一程式,請直接設定變數month 的值,代表月份,然後判斷其所屬的季節(3~5
月為春季,6~8 月為夏季,9~11 月為秋季,12~2 月為冬季)
*/

import java.util.Scanner;
public class P5_2_7 {
public static void main(String[] args) {
System.out.println("請輸入月份的值");
Scanner sc=new Scanner(System.in);
int month=sc.nextInt();
if(month>12){
System.out.println("月份不存在"+month+"月");
}else if(month/3==1){
System.out.println("春季"+month+"月");
}else if(month/3==2){
System.out.println("夏季"+month+"月");
}
else if(month/3==3){
System.out.println("秋季"+month+"月");
}else{
System.out.println("冬季"+month+"月");
}

}

}

/*

請輸入月份的值
10
秋季10月

*/

arrow
arrow
    全站熱搜

    goodlucky23 發表在 痞客邦 留言(0) 人氣()