public class Bissextile {
在翔安等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站制作、成都網(wǎng)站建設(shè) 網(wǎng)站設(shè)計制作按需網(wǎng)站建設(shè),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),網(wǎng)絡(luò)營銷推廣,外貿(mào)網(wǎng)站制作,翔安網(wǎng)站建設(shè)費用合理。
public static void main(String[] args) {
Bissextile instance = new Bissextile();
while (!instance.isBissextile()) {
System.out.println("不是閏年\n");
}
System.out.println("是閏年");
}
private boolean isBissextile() {
System.out.println("請輸入年份:");
Scanner scanner = new Scanner(System.in);
int year = scanner.nextInt();
return (year % 4 == 0 year % 100 != 0) || (year % 400 == 0);
}
}
其實沒有錯誤,因為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 leap year");
else System.out.print(year+" is not leap year");
}
public static void main(String[] args) {
leapYear(1000);
}
}
如果你輸入的數(shù)字的長度不等于4是判斷年份是幾位數(shù)!其實我覺得可以不寫!因為年份不是從千年開始的!
package com.ceshi.year;
import java.util.Scanner;
public class TestYear { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("請輸入要判定的年份:"); int year = scanner.nextInt(); if(year%4==0 || year%400==0) { System.out.println(year+" 是閏年"); } else { System.out.println(year+" 不是閏年"); } }}