久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      java實現(xiàn)計算某年某月的天數(shù)

      java實現(xiàn)計算某年某月的天數(shù)

      在計算某年某月的天數(shù)時,需要注意平年閏年。

      分析:閏年具體的判定方法就要看它的判定條件:四年一閏 , 百年不閏 ,400年再閏。而計算該年該月的天數(shù),又分大月和小月,特殊月份2月之分。

      (視頻教程推薦:java視頻)

      具體代碼:

      import java.util.Scanner; import java.text.MessageFormat; public class Test02 {     public static void main(String[] args) {         Scanner input = new Scanner(System.in);         System.out.print("請輸入一個4位數(shù)的年份(1900~2099):");         int year = input.nextInt();          if(year >=1900 && year <= 2099){             System.out.println("請輸入月份(1~12):");             int month = input.nextInt();             if(month >=1 && month <= 12){              // 計算該年該月的天數(shù)              // 大月和小月,特殊月份2月                 int day=31;                 switch(month){                     case 4: case 6: case 9: case 11:                         day=30;                         break;                     case 2:                         // 判定條件:四年一閏 && 百年不閏 || 400年再閏                         boolean isLeapYear=(year%4==0 && year%100!=0) || year%400==0;                         //三元運算符判定                         day= isLeapYear ? 29 : 28;                         break;                 }                 String info = MessageFormat.format("{0}年{1}月{2}天",year,month,day);                 System.out.println(info);             }else{                 System.out.println("請輸入正確的月份");             }         }else{             System.out.println("請輸入一個1900~2099之間的年份");         }     } }

      推薦教程:java開發(fā)入門

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號