本版本是在原由版本上进行修改的

//增强版

/**

* 新增功能:

* 1:对输入的月份和天数进行判断;

* 2:可以循环输入

*/

效果图:

判断是否是润年plush版_源码下载
代码:

package com.kaigejava.testyear;


import java.util.Scanner;


public class TestYearPlush {

//增强版

/**

* 新增功能:

* 1:对输入的月份和天数进行判断;

* 2:可以循环输入

*/

public static void main(String[] args) {

boolean isok = true;

while(isok){

int inyear;

int month;

int day;

System.out.println("请输入年份:");

Scanner sc=new Scanner(System.in);

inyear=sc.nextInt();

System.out.println("请输入月份:");

Scanner scmonth=new Scanner(System.in);

month=scmonth.nextInt();

if(month>12||month<1){

System.out.println("您输入的月份有误,月份输入范围为:1--12.请重新输入");

continue;

}

System.out.println("请输入日期:");

Scanner scday=new Scanner(System.in);

day=scday.nextInt();

if(day>31||day<1){

System.out.println("您输入的天数有误,每月天数输入范围为:1--31.请重新输入");

continue;

}

Year year = new Year(inyear,month,day);

boolean isjudgeyear = year.judgeyear(inyear);

if (isjudgeyear){

System.out.println("您输入的时间是"+inyear+"年"+month+"月"+day+"日。"+inyear + "是闰年!");

}

else{

System.out.println("您输入的时间是"+inyear+"年"+month+"月"+day+"日。"+inyear + "不是闰年!");

}


System.out.println("是否继续输入? 1:是 2:否");

Scanner inok=new Scanner(System.in);

String ok = inok.nextLine();

if("1".equals(ok)){

isok=true;

}else if("2".equals(ok)){

isok=false;

System.out.println("谢谢使用");

}else{

isok=false;

System.out.println("您输入的有误!");

}

}

}

}