prss.net
当前位置:首页 >> jAvA判断闰年代码 >>

jAvA判断闰年代码

其实没有错误,因为1000不是瑞年,所以没有输出 public class CountDate { public static void leapYear(int year) { if (((year % 100 == 0) && (year % 400 == 0)) || ((year % 100 != 0) && (year % 4 == 0))) System.out.print(year + " is ...

int year; if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){ 是闰年 }else{ 不是闰年 }

public class Test { //输入年份判断是否为闰年public static void main(String[] args) {int year;System.out.println("请输入年份:");Scanner sc=new Scanner(System.in); year=sc.nextInt();if(year%4==0&&year%100!=0||year%400==0) {System...

public boolean checkLeapYear(int year){ boolean flag=false; if((year%4 == 0) && ((year%100 != 0) || (year%400 == 0)){ flag=true; } return flag;}

public void isLeapYear(int years){ Calendar cal=Calendar.getInstance(); cal.set(years,Calendar.DECEMBER,31); if(cal.get(Calendar.DAY_OF_YEAR)==366){ System.out.println(years+"年是闰年"); }else{ System.out.println(years+"年平年"...

import java.util.Scanner;public class Test1 {public static void main(String[] args) {int a;Scanner in = new Scanner(System.in);a = in.nextInt();//能被400整除是闰年//能被4整除,不能被100整除是闰年if ((a%400 == 0) || (a%4 == 0 &&...

去掉里面的类

if一行 结尾多了一个分号 删掉就没问题了。

//随便输入一个公元年份,判断是不是闰年 package lianxi; import java.util.Scanner; public class RunNian { public static void main(String[] args) { Scanner year = new Scanner(System.in); System.out.println("请输入年份:"); int y =...

网站首页 | 网站地图
All rights reserved Powered by www.prss.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com