Help

哪位高手帮我看一段JAVA的程序哪错了,3Q了!
import java.io.*;
import java.lang.String;
public class WeekDay {

 /**
  * @param args
  */
 public static int weekday;
 public static int month;
 public WeekDay(){
  weekday=5;
  month=10;
 }
 public WeekDay(int monthin,int weekdayin){
  month=monthin;
  weekday=weekdayin;
 }
 public String getweekdayname(){
  switch(weekday){
  case 1:return "Monday";
  case 2:return "Tuesday";
  case 3:return "Wednesday";
  case 4:return "Thursday";
  case 5:return "Saturday";
  case 6:return "Sunday";
  case 0:return " ";
  }
 }
 public String getmonthname(){
  switch(month){
  case 1:return "January";
  case 2:return "February";
  case 3:return "March";
  case 4:return "April";
  case 5:return "May";
  case 6:return "June";
  case 7:return "July";
  case 8:return "Augest";
  case 9:return "September";
  case 10:return "October";
  case 11:return "November";
  case 12:return "December";
  default:return " ";
  }
 }
 public static void main(String[] args) {
  public int monthin=0,dayin=0;
 public int weekdayin=3;
 public int num;
 System.out.print("请输入月份和日期(输入回车表示默认选择10月1日),月份:");
 InputStreamReader ir;
 BufferedReader in;
 String s=new String();
 
 boolean b=true;
try{
 ir=new InputStreamReader(System.in);
 in=new BufferedReader(ir);
 while(b){
  s=in.readLine();
  try{
     monthin=Integer.parseInt(s);
     if(monthin<1||monthin>12){
       System.out.println("月份输入错误!请重试:");
       continue;
  }
  b=false;
 }catch(NumberFormatException e){
  if(s.length()==0){
   WeekDay example=new WeekDay();
   System.out.println(example.getmonthname()+","+1+",2004 is"+example.getweekdayname()+"!");
   return;
  }
  else{
   System.out.println("非数字!请重试:");
   continue;
  }
 }
}
}catch (IOException e){
 System.out.println(e);
}
switch(monthin){
 case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:num=31;break;
    case 4:
    case 6:
    case 9:
    case 11:num=30;break;
    case 2: num=29;break;
    default:num=0;break;
}
    System.out.print("请输入日期:");
    b=true;
    try{
     InputStreamReader ir = new InputStreamReader(System.in);
     BufferedReader in = new BufferedReader(ir);
     boolean b;
  while(b){
   s=in.readLine();
   try{
             dayin = Integer.parseInt(s);
          if(dayin<1||dayin>num){
       System.out.println("日期输入错误!请重试:");
       continue;
      }
      b=false;
     }catch(NumberFormatException e){
      System.out.println("非数字!请重试:");
      continue;
     }
    }
}catch (IOException e){
 System.out.println(e);
}
for(int i=1;i<monthin;i++){
 switch(i){
    case 1:
     case 3:
     case 5:
     case 7:
     case 8:
     case 10:
     case 12:num=31;break;
     case 4:
     case 6:
     case 9:
     case 11:num=30;break;
     case 2: num=29;break;
     default:num=0;break;
 }
 weekdayin = weekdayin+num;
}
 weekdayin=weekdayin+dayin;
 weekdayin=weekdayin%7;
 WeekDay example =new WeekDay(monthin,weekdayin);
 System.out.println(example.getmonthname()+","+dayin+",2004 is"+example.getweekname()+"!");
  }
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值