import java.util.*;
//定义一个myjava类
public class myjava{
public static void main(String[] args)
{
Random r = new Random();
int mon = r.nextInt(12)+1;
int year =2000 + r.nextInt(10);
int day = r.nextInt(30);
System.out.println(year+"年"+mon+"月"+day+"日");
year temp = new year();
if(temp.isRunnis(year)==true)
System.out.println(year+"年是闰年");
else
System.out.println(year+"年不是闰年");
System.out.println(year+"年的第"+mon+"月有"+temp.getMonDay(year,mon)+"天");
}
}
//定义一个year的类
class year
{
int mon;
int year;
int day;
//定义一个isRunnis方法
public boolean isRunnis(int year)
{
boolean result = false;
if(year%4==0&&(year%100)!=0||year%400==0)
result=true;
return result;
}
//获取月数
public int getMonDay(int year,int mon)
{
boolean flag=new year().isRunnis(year);
int february = 28;
int result = 30;
if(flag == true)
february=29;
switch(mon)
{
case 1:case 3:case 5:case 7:case 8:case 10:case 12:
result = 31;break;
case 2:result = february;break;
}
return result;
}
//获取天数功能
public int getDay(int year,int mon,int day)
{
int mons[]={31,28,31,30,31,30,31,31,30,31,30,31};
boolean flag = new year().isRunnis(year);
int result=0;
int i=0;
if(flag==true)
mons[1]=29;
for(i=1;i<mon;i++)
result = result=result+mons[i];
return result+day;
}
}