excise0326.java
来自「一个很小的JAVA编程,适用于初级学习JAVA语言的同学学习,简单易懂」· Java 代码 · 共 36 行
JAVA
36 行
class Excise0210{
private int year;
public void set(int y){year=y;}
public boolean isLeap(){
if(year%400==0||(year%400!=0&&year%4==0)) return true;
else return false;
}
}
class Excise0326{
static int dayInMonth(int y, int m){
int D;
Excise0210 Y=new Excise0210();
Y.set(y);
switch(m){
case 2: if(Y.isLeap()==true) D=29;else D=28; break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: D=31; break;
case 4:
case 6:
case 9:
case 11: D=30; break;
default: System.out.println("Unvalid month!");D=0;
}
return D;}
public static void main(String args[]){
int day=dayInMonth(200400,2);
System.out.println("it has "+day+" days.");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?