Topic: 求某年某月是多少天

  Print this page

1.求某年某月是多少天 Copy to clipboard
Posted by: 丫丫
Posted on: 2007-09-18 10:00

public class DayShower
{
public static void main(String []args)
{
int yearIn=2004;
int monthIn=5;
if(args.length>0)
monthIn=Integer.parseInt(args[0]);
if(args.length>1)
yearIn=Integer.parseInt(args[1]);
System.out.println(yearIn+"年"+monthIn+"月有"+countDays(monthIn,yearIn)+"天");
}
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)
count=29;
else
count=28;
if((year % 100 ==0) & (year % 400 !=0))
count=28;
}
return count;
}
}

2.Re:求某年某月是多少天 [Re: 丫丫] Copy to clipboard
Posted by: liuqianqian
Posted on: 2008-01-30 19:46

你是要说这个程序是这么写的吗?嗬嗬!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923