| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 450 人关注过本帖
标题:在个程序什么错误
取消只看楼主 加入收藏
laishang
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-3-2
收藏
 问题点数:0 回复次数:1 
在个程序什么错误
public class Time {
int day,yesterday,tomorrow,month,lastmonth;
int nextmonth,year,lastyear,nextyear;
Time(int y,int m,int d){
year=y;
month=m;
day=d;


}
boolean leap=false;
leap=(year%400==0)|(year%100!=0)&(year%4==0);
public void shijian(){
switch(month)
{
case 1:
if(1<day<31)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==1)
lastmonth=12;yesterday=31;lastyear=year-1;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==31)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month+1;tomorrow=1;nextyear=year;
case 4:
case 6:
case 8:
case 9:
case 11:

if(1<day<30)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==1)
lastmonth=month-1;yesterday=31;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==30)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month+1;tomorrow=1;nextyear=year;
case 5:
case 7:
case 10:
if(1<day<31)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==1)
lastmonth=month-1;yesterday=30;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==31)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month+1;tomorrow=1;nextyear=year;
case 12:
if(1<day<31)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==1)
lastmonth=month-1;yesterday=30;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==31)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=1;tomorrow=1;nextyear=year+1;
case 2:
if(leap){

if(1<day<29)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==1)
lastmonth=month-1;yesterday=31;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==29)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month+1;tomorrow=1;nextyear=year;
}
else
{
if(1<day<28)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==1)
lastmonth=month-1;yesterday=31;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==28)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month+1;tomorrow=1;nextyear=year;
}
case 3:
if(1<day<31)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
if(day==1)
if(leap){
lastmonth=month-1;yesterday=29;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
}
else{
lastmonth=month-1;yesterday=28;lastyear=year;
nextmonth=month;tomorrow=day+1;nextyear=year;
}
if(day==31)
lastmonth=month;yesterday=day-1;lastyear=year;
nextmonth=month+1;tomorrow=1;nextyear=year;
}
}
public void print(){
System.out.println("今天"+year+" "+month+" "+day);
System.out.println("昨天"+lastyear+" "+lastmonth+" "+yesterday);
System.out.println("明天"+nextyear+" "+nextmonth+" "+tomorrow);
}
public static void main(String[] args) {

Time a=new Time(2000,1,22);
a.print();
}
}
2006-03-21 23:20
laishang
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-3-2
收藏
得分:0 
谢谢楼上的,我已经按你的方法改过来了
2006-03-22 14:24
快速回复:在个程序什么错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017635 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved