⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 daycounter.java

📁 非常好的JAVA学习资料
💻 JAVA
字号:
import java.io.*;
class DayCounter {
    public static void main(String[] arguments) throws IOException
    {
      int year,month;
      String str;
      BufferedReader buf;
      buf=new BufferedReader(new InputStreamReader(System.in));
      System.out.print("Input year number:");
 str=buf.readLine();        
      year=Integer.parseInt(str);    
      System.out.print("Input the month number:");
      str=buf.readLine();        
      month=Integer.parseInt(str); 
        System.out.println(month + "/" + year + " has "
            + countDays(month, year) + " days.");
     }

    static int countDays(int month, int year) {
        int count = -1;
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                count = 31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                count = 30;
                break;
            case 2:
                if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
                    count = 29;
                else
                    count = 28;
        }
        return count;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -