Fresh.587 2021-10-04 19:28 采纳率: 88%
浏览 55
已结题

java运行时出现Exception in thread "main" java.lang怎样更改

完整代码如下,不清楚问题出现在哪,请求指点!

package javashiyaner;
import java.util.Scanner;
public class Javashiyaner {   
    public static void main(String[] args) {   
  int year;    
 int month; 
    Scanner reader=new Scanner(System.in);     System.out.println("请输入年份:");   
  year=reader.nextInt();  
   System.out.println("请输入月份:");   
  month=reader.nextInt();    
 while(true){         if(month<1||month>12)             System.out.println("输入有误请重新输入:");         else break;     }      
  judge(year,month);    }   
 private static void judge(int year, int month) {        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.    }
    }
class judge{
public judge(int nian,int yue){      
  switch(yue){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:System.out.println("该月有31天");break;
case 4:
case 6:
case 9:
case 11:System.out.println("该月有30天");break;  
      case 2:
if(nian%4==0&&nian%100!=0||nian%400==0)
System.out.println("该月有29天");
else System.out.println("该月有28天");}
}


}

img

  • 写回答

2条回答 默认 最新

  • stacksoverflow 2021-10-04 19:36
    关注
    
    package javashiyaner;
    
    import java.util.Scanner;
    
    public class Javashiyaner {
        public static void main(String[] args) {
            int year;
            int month;
            Scanner reader = new Scanner(System.in);
            System.out.println("请输入年份:");
            year = reader.nextInt();
            System.out.println("请输入月份:");
            month = reader.nextInt();
            while (true) {
                if (month < 1 || month > 12)
                    System.out.println("输入有误请重新输入:");
                else
                    break;
            }
            judge(year, month);
        }
    
        public static void judge(int nian, int yue) {
            switch (yue) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                System.out.println("该月有31天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println("该月有30天");
                break;
            case 2:
                if (nian % 4 == 0 && nian % 100 != 0 || nian % 400 == 0)
                    System.out.println("该月有29天");
                else
                    System.out.println("该月有28天");
            }
        }
    
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月14日
  • 已采纳回答 10月6日
  • 创建了问题 10月4日

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效